Table of Contents

Create XR Origin

Through the following content, you will learn how to create and configure an XR Origin and XR Origin Child in a Unity scene.

Before you begin

  • Understand the basic concepts, components, and workflow of a session through Introduction to ARSession.
  • Understand the basic concepts, components, and lifecycle of XR Origin through XR Origin.

Create XR Origin (EasyAR)

Right-click on a blank area in the Hierarchy view, and select EasyAR Sense > Origin > Origin : XR Origin (EasyAR) from the menu to create a complete origin structure.

alt text

In scripts, you can use ARSessionFactory.CreateOrigin() to create it:

ARSessionFactory.CreateOrigin();
Note

When the session is running, if there is no correct XR Origin structure in the scene, an XR Origin and an XR Origin Child will be automatically created.

[Optional] Create XR Origin (Unity XR)

Right-click on a blank area in the Hierarchy view, and select XR > XR Origin (Mobile AR) from the menu to create an XR Origin suitable for AR Foundation. For detailed information and creation methods about this XR Origin, refer to the Unity official documentation: Add Unity XR's XR Origin to the Scene.

Note

When using a headset, be sure to refer to the corresponding headset SDK documentation for operations.

When using the XR Origin provided by the Unity XR framework, you need to manually add an XR Origin Child.

Add XR Origin Child to XR Origin

In the Hierarchy view, select XR Origin (EasyAR) or XR Origin, right-click, and select EasyAR Sense > Origin > Origin : XR Origin Child from the menu to add an XR Origin Child under the XR Origin.

alt text

In scripts, you can use ARSessionFactory.AddOriginChild(GameObject):

ARSessionFactory.AddOriginChild(origin);

You can add any number of XR Origin Children, and they will all work correctly. However, for objects generated internally by the session, only the first XR Origin Child will be used as the parent node.

Note

When the session is running, if there is no correct XR Origin Child structure in the scene, an XR Origin Child will be automatically created.

Next steps