Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

正在為Android匯出

設定

大多數獨立耳機都在 Android 上運作,而 OpenXR 支援正在進入這些平台。

在遵循此處特定於 OpenXR 的說明之前,您需要先設定係統以匯出到 Android,包括:

  • Installing OpenJDK 17

  • 安裝 Android Studio

  • 建立 debug.keystore

  • 配置Godot中Android SDK和debug.keystore的位置

請參閱 doc_exporting_for_android 以了解完整詳細信息,並在完成這些步驟後返回此處。

Gradle Android build

備註

OpenXR 規範並未新增對 Android 平台的官方支援,最初導致各個供應商建立自訂載入器以使 OpenXR 在其耳機上可用。雖然長期期望所有供應商都將採用官方 OpenXR 載入器,但目前需要將這些載入器新增到您的專案中。

In order to include the vendor-specific OpenXR loader into your project, you will need to setup a gradle Android build.

專案* 選單中選擇 **安裝 Android 建置範本...

../../_images/android_gradle_build.webp

這將在您的專案中建立一個名為 android 的資料夾,其中包含 Android 上所需的所有運作時檔案。現在您可以自訂此安裝。 Godot 不會在編輯器中顯示它,但您可以使用檔案瀏覽器找到它。

You can read more about gradle builds here: Gradle builds for Android.

Installing the vendors plugin

警告

The Android plugin structure has been restructured in Godot 4.2, and the loader plugin was renamed to vendors plugin as it now includes more than just loaders. If you've previously installed the loader plugin you need to delete it from the android/plugins folder. The loader plugin available in the asset library is still the old one, it will be updated to the new vendor plugin after 4.2 is released.

The vendors plugin can be downloaded from the asset library, search for OpenXR and install the plugin:

../../_images/openxr_loader_asset_lib.webp

這會將所需檔案下載到該資料夾中.

Alternatively you can manually install the vendors plugin by downloading the v2.x version of the plugin from the release page here.

You will need to copy the assets/addons/godotopenxrvendors folder from the zip file into your projects assets/addons folder.

You can find the main repository of the vendors plugin here.

Enabling the vendors plugin

The vendors plugin needs to be enabled before the export settings become accessible. Open Project and select Project Settings.... Go to the Plugins tab. Enable the GodotOpenXRVendors plugin.

../../_images/xr_enable_vendors_plugin.webp

建立 UWP 匯出樣板

您需要為每個裝置設定單獨的匯出預設,因為每個裝置都需要包含自己的載入程式。

開啟**專案**並選擇**匯出..**。點擊“新增..”並選擇“Android”。接下來更改您要設定的裝置的匯出預設的名稱,例如 Meta Quest。並啟用**使用 Gradle Build**。如果您想使用一鍵部署(如下所述),請確保啟用 Runnable

如果加載器插件安裝正確,您應該找到不同耳機的條目,選擇元條目:

../../_images/android_meta_quest.webp

也將 XR 模式 變更為 OpenXR

捲動到列表底部,您會發現其他 XR 功能部分,目前僅**元 XR 功能**可用。此處的手部追蹤和直通設定目前僅適用於 Meta Quest,如果您想使用這些功能,則需要選擇適當的設定。

../../_images/xr_export_features.webp

灰色的節點無法重新命名。代表這些節點有母場景

備註

Meta Quest、Pico 和 Lynx R1 耳機有單獨的載入程式。

The fourth option is the official Khronos loader, in due time all headsets should work with this loader. At the moment this loader has been tested with the Magic Leap 2 and standalone HTC headsets.

警告

雖然 Mobile Vulkan 渲染器針對行動裝置進行了許多最佳化,但我們仍在解決問題。當針對基於 Android 的 XR 裝置時,強烈建議暫時使用 OpenGL 渲染器。

請注意,我們正在等待各種裝置上的驅動程式更新,然後 Vulkan 支援才能在這些裝置上運作。

通過 Godot 編輯器在裝置上運作

使用 :ref:`doc_one-click_deploy`直接從 Godot 編輯器啟動它:

../../_images/android_one_click_deploy.webp

對於某些平台上的某些裝置,您可能需要執行一些額外的步驟才能正確識別您的裝置,因此請務必檢查耳機供應商的開發人員檔案。

只有開啟開發者模式,才能夠向 Meta Quest 部署遊戲。這個模式可以使用手機上安裝的 Oculus 支援應用開啟。請`按照 Oculus 開發者網站上的說明操作 <https://developer.oculus.com/documentation/native/android/mobile-device-setup/>`__。

如果您對一鍵部署有任何問題,請檢查:ref:故障排除部分 <doc_one-click_deploy_troubleshooting>