Active control strategy for target and origin
Through the following content, you will learn about the default display and hide strategies for objects under target and origin, and how to adjust them as needed.
Before you begin
- Read Target to understand the basic concepts, states, and lifecycle of a target.
- Read XR Origin to understand the basic concepts, composition, and lifecycle of an XR origin.
Active control and control strategy types
During the session runtime, the target and origin will undergo state changes such as tracking and loss. Through active control strategies, the display and hide behaviors of objects under the target and origin can be automatically managed.
In Unity, the ActiveController component is responsible for automatically managing the GameObject.activeSelf state of target and origin objects, so that the content is displayed after the target is tracked or motion tracking starts tracking, and hidden before the target is lost or motion tracking is successfully initialized.
The ActiveController provides two different active control strategies:
- ActiveWhileTracked: When tracked, the GameObject will be activated (GameObject.activeSelf is set to
true); when tracking is lost, the GameObject will be deactivated (GameObject.activeSelf is set tofalse). - ActiveAfterFirstTracked: Before the first tracking, the GameObject will be deactivated (GameObject.activeSelf is set to
false); once successfully tracked, the GameObject will remain activated (GameObject.activeSelf is set totrue).
By default, the TargetController uses the ActiveWhileTracked strategy, which means that when the target is tracked, the target and its content will be activated, and when tracking is lost, the target and its content will be deactivated.
By default, the XROriginChildController uses the ActiveAfterFirstTracked strategy, which means that before motion tracking is successfully initialized, the origin and its content will be deactivated, and once motion tracking is successfully initialized, the origin and its content will remain activated.
Select different active control strategies
Open the Inspector panel, select Input from the Strategy dropdown menu.

Then choose the desired active control strategy on the right to override the default strategy.

In scripts, you can override the default active control strategy through the OverrideStrategy property.
For example, the following code shows how to set the target's active control strategy to ActiveAfterFirstTracked:
target.ActiveController.OverrideStrategy = ActiveController.Strategy.ActiveAfterFirstTracked;
Changes to the active strategy take effect immediately and update GameObject.activeSelf based on the current tracking status.
Disable active control
If you need to completely disable active control, such as for on-demand control, you can turn off active control by disabling the ActiveController component.

In scripts, you can disable active control by setting the ActiveController.enabled property.
target.ActiveController.enabled = false;
Changes to the enabled property take effect immediately and will no longer update GameObject.activeSelf based on tracking status. If you re-enable the ActiveController component, GameObject.activeSelf will update based on the current tracking status.