Unity 的 AR Foundation 適用的 ARCore 擴充功能支援 4.x 版和 5.x 版的 AR Foundation。如要將現有的 AR 專案從 AR Foundation 4.x 升級至 AR Foundation 5.x,請按照下列步驟操作:
僅在 Unity 2021.x 以下版本中:
部分 Unity 套件會繫結至特定的 Unity 編輯器版本。 在部分 Unity 編輯器版本中,您可能需要編輯 Unity 專案中的套件資訊清單,以便更新為 AR Foundation 5.x。詳情請參閱「在 Unity 2021 中存取 AR Foundation 5.0」。確認 Packages/manifest.json 包含下列套件的這些版本:
"dependencies": { -- other dependencies -- "com.unity.xr.arcore": "5.0.5", "com.unity.xr.arfoundation": "5.0.5", "com.unity.xr.arkit": "5.0.5", -- other dependencies -- }
適用於 Unity AR Foundation 的 ARCore Extensions 使用 ARCORE_USE_ARF_5 自訂指令碼符號 判斷版本相容性。為了與 AR Foundation 5.x 相容,請新增 ARCORE_USE_ARF_5 自訂指令碼符號:
- 在「Edit」>「Project Settings」>「Player」>「Other Settings」中,向下捲動至「Script Compilation」。
- 使用 + 按鈕新增 ARCORE_USE_ARF_5。
- 選取「套用」。
由於依附於
TrackedPoseDriver
,AR Foundation 5.x 需要輸入系統套件。ARCore Extensions 範例場景需要舊版輸入模組。如要同時支援輸入系統套件和舊版的輸入管理員,請在「Project Settings」>「Player」>「Other Settings」中,將「Active Input Handling」設為「Both」。
請按照 Unity AR Foundation 的升級和遷移指南中的其他步驟操作。