Class OpenXRHandSubsystemManager
Manages the lifecycle of the XRHandSubsystem and updater created by the HandTracking OpenXR feature. Toggle this component's enabled state to start and stop the subsystem.
Inherited Members
Namespace: UnityEngine.XR.Hands.OpenXR
Assembly: Unity.XR.Hands.dll
Syntax
public class OpenXRHandSubsystemManager : MonoBehaviour
Remarks
On Awake(), if the subsystem has not been created yet (for example when automaticallyInitializeSubsystem is false), the component disables itself. Re-enable it from your own code when ready and OnEnable() will create and start the subsystem.
Examples
The following example mocks how a permissions checking script might respond to permission requests for hand tracking by enabling or disabling this component.
#if UNITY_OPENXR_PACKAGE
using UnityEngine;
using UnityEngine.XR.Hands.OpenXR;
/// <summary>
/// A sample demonstrating how to use the <see cref="OpenXRHandSubsystemManager"/>
/// to start and stop hand tracking based on platform-specific permission requests.
/// </summary>
public class SubsystemManagerSample : MonoBehaviour
{
[SerializeField]
OpenXRHandSubsystemManager handSubsystemManager;
void Awake()
{
if (handSubsystemManager == null)
{
handSubsystemManager =
FindAnyObjectByType<OpenXRHandSubsystemManager>();
}
}
void Start()
{
// Make some platform-specific permission requests
}
/// <summary>
/// Called when permission for hand tracking is granted.
/// </summary>
public void OnPermissionGranted()
{
// Start hand tracking
handSubsystemManager.enabled = true;
}
/// <summary>
/// Called when permission for hand tracking is denied.
/// </summary>
public void OnPermissionDenied()
{
// Stop hand tracking
handSubsystemManager.enabled = false;
}
}
#endif // UNITY_OPENXR_PACKAGE
Methods
Awake()
Called when the script instance is being loaded. Disables this component if the subsystem has not been created yet.
Declaration
protected void Awake()
OnDisable()
Called when the component becomes disabled or inactive. Stops the subsystem and updater.
Declaration
protected void OnDisable()
OnEnable()
Called when the component becomes enabled and active. If the Hand Tracking OpenXR feature is enabled, creates the subsystem and updater if needed, then starts them.
Declaration
protected void OnEnable()