使用 ARCore Extensions for Unity 配置 ARCore 会话
配置 ARCore 会话,为您的应用构建 AR 体验。
什么是会话?
所有 AR 流程(例如运动跟踪、环境理解和光照估测)都发生在 ARCore 会话内。ARSession
是 ARCore API 的主要入口点。它可管理 AR 系统状态并处理会话生命周期,让应用能够创建、配置、启动或停止会话。最重要的是,它支持应用接收帧,以便访问相机图像和设备姿势。
该会话可用于配置以下功能:
设置 AR Foundation 和 ARCore Extensions
您必须先设置 AR Foundation,然后才能使用 ARCore 扩展程序。如需了解如何设置 AR 场景,请参阅 AR Foundation 设置文档。
您必须先设置 ARCore 扩展程序,然后才能配置 ARCore 会话。如果您尚未参阅,请参阅 ARCore Extensions 设置文档。
在 ARCore 中创建新的会话配置。
在 Unity 中,前往 Assets >
Create > XR > ARCore Extensions Config 以创建新的会话配置。
默认配置如下所示:

在 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 的迁移指南。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-11-09。
[null,null,["最后更新时间 (UTC):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."]]],["An ARCore session is essential for AR processes like motion tracking and lighting estimation. `ARSession` manages the AR system state, including session creation and configuration, and enables access to camera images and device pose. Before configuring the ARCore session, AR Foundation and ARCore Extensions must be set up. You need to create an `ARCore Extensions Config` asset in Unity and connect it to the `ARCore Extensions` object. Session management is done using `LoaderUtility` functions in newer versions of AR Foundation.\n"]]