使用 Unity 的 ARCore 擴充功能設定 ARCore 工作階段
設定 ARCore 工作階段,為您的應用程式打造 AR 體驗。
什麼是工作階段?
所有 擴增實境程序 (例如動作追蹤、環境感知和光源預測) 都會在 ARCore 工作階段中執行。ARSession
是 ARCore API 的主要進入點。它會管理 AR 系統狀態,並處理工作階段生命週期,讓應用程式建立、設定、啟動或停止工作階段。最重要的是,這項功能可讓應用程式接收可存取相機影像和裝置姿勢的框架。
這個工作階段可用於設定下列功能:
設定 AR Foundation 和 ARCore 擴充功能
您必須先設定 AR Foundation,才能使用 ARCore 擴充功能。如需 AR 場景設定操作說明,請參閱 AR Foundation 設定說明文件。
您必須先設定 ARCore 擴充功能,才能設定 ARCore 工作階段。如果尚未設定,請參閱 ARCore Extensions 設定文件。
在 ARCore 中建立新的工作階段設定。
在 Unity 中,前往 Assets >
Create > XR > ARCore Extensions Config 建立新的工作階段設定。
預設設定如下所示:
![](https://developers.google.cn/static/ar/develop/unity-arf/images/unity-arf-default-session-config.png?authuser=19&hl=zh-tw)
在 Hierarchy 窗格中,選取 ARCore Extensions 物件。
在「Inspector」窗格的「ARCore Extensions Config」欄位中,按一下目標「
」按鈕,然後連結至「ARCoreExtensionsConfig」資產。
AR 工作階段管理
在 AR Foundation 2.1 和 3.1 中,刪除 ARSession 遊戲物件會刪除底層 ARCore 工作階段。
從 AR Foundation 4.0 開始,您必須改用 LoaderUtility
函式來刪除及建立子系統。請參閱 AR Foundation 3.x 版到 4.x 版遷移指南。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-11-09 (世界標準時間)。
[null,null,["上次更新時間:2024-11-09 (世界標準時間)。"],[[["An ARCore session manages all AR processes like motion tracking and environmental understanding, and is accessed through the `ARSession` object."],["Before configuring an ARCore session, ensure both AR Foundation and ARCore Extensions are properly set up in your Unity project."],["You can configure extension features within the ARCoreExtensionsConfig asset, which allows you to customize session behavior."],["Starting with AR Foundation 4.0, session management is handled through `LoaderUtility` functions instead of destroying the `ARSession` game object."],["After configuring your session, explore the provided quickstart guides for Android and iOS to begin building AR experiences with ARCore Extensions."]]],[]]