Class OpenXRFeature
A Unity OpenXR Feature. This class can be inherited from to add feature specific data and logic. Feature-specific settings are serialized for access at runtime.
Inherited Members
Namespace: UnityEngine.XR.OpenXR.Features
Syntax
[Serializable]
public abstract class OpenXRFeature : ScriptableObject
Properties
enabled
Feature is enabled and will be started when the OpenXR loader is initialized.
Note that the enabled state of a feature cannot be modified once OpenXR is initialized and can be used at runtime to determine if a feature successfully initialized.
Declaration
public bool enabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
xrGetInstanceProcAddr
Accessor for xrGetInstanceProcAddr function pointer.
Declaration
protected static IntPtr xrGetInstanceProcAddr { get; }
Property Value
Type | Description |
---|---|
IntPtr |
Methods
CreateSubsystem<TDescriptor, TSubsystem>(List<TDescriptor>, String)
Creates a subsystem based on a given a list of descriptors and a specific subsystem id. Promoted to public for extensions.
Declaration
protected void CreateSubsystem<TDescriptor, TSubsystem>(List<TDescriptor> descriptors, string id)
where TDescriptor : ISubsystemDescriptor where TSubsystem : ISubsystem
Parameters
Type | Name | Description |
---|---|---|
List<TDescriptor> | descriptors | List of TDescriptor instances to use for subsystem matching |
String | id | The identifier key of the particular subsystem implementation being requested |
Type Parameters
Name | Description |
---|---|
TDescriptor | The descriptor type being passed in |
TSubsystem | The subsystem type being requested |
DestroySubsystem<T>()
Destroys a subsystem instance of a given type. Subsystem is assumed to already be loaded from a previous call to CreateSubsystem. Promoted to public for extensions.
Declaration
protected void DestroySubsystem<T>()
where T : class, ISubsystem
Type Parameters
Name | Description |
---|---|
T | A subclass of ISubsystem |
GetAction(InputAction)
Returns XrAction handle bound to the given InputAction.
Declaration
protected ulong GetAction(InputAction inputAction)
Parameters
Type | Name | Description |
---|---|---|
InputAction | inputAction | Action to retrieve XrAction handles for |
Returns
Type | Description |
---|---|
UInt64 | XrAction handle bound to the given InputAction or 0 if there is no bound XrAction |
GetCurrentAppSpace()
Returns the current app space.
Declaration
protected static ulong GetCurrentAppSpace()
Returns
Type | Description |
---|---|
UInt64 | Current app space |
GetCurrentInteractionProfile(String)
Returns the path of the current interaction profile for the given user path.
Declaration
protected static ulong GetCurrentInteractionProfile(string userPath)
Parameters
Type | Name | Description |
---|---|---|
String | userPath | User path |
Returns
Type | Description |
---|---|
UInt64 | A path to the interaction profile, or XrPath.none if the path could not be retrieved. |
GetCurrentInteractionProfile(UInt64)
Returns the path of the current interaction profile for the given user path.
Declaration
protected static ulong GetCurrentInteractionProfile(ulong userPath)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | userPath | OpenXR User Path (eg: /user/hand/left) |
Returns
Type | Description |
---|---|
UInt64 | A path to the interaction profile, or XrPath.none if the path could not be retrieved. |
HookGetInstanceProcAddr(IntPtr)
Called to hook xrGetInstanceProcAddr. Returning a different function pointer allows intercepting any OpenXR method.
Declaration
protected virtual IntPtr HookGetInstanceProcAddr(IntPtr func)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | func | xrGetInstanceProcAddr native function pointer |
Returns
Type | Description |
---|---|
IntPtr | Function pointer that Unity will use to look up OpenXR native functions. |
OnAppSpaceChange(UInt64)
Called when the reference xrSpace for the app changes.
Declaration
protected virtual void OnAppSpaceChange(ulong xrSpace)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrSpace | Handle of the xrSpace |
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
protected virtual void OnEnable()
OnEnvironmentBlendModeChange(Int32)
Notification to the feature implementer that the environment blend mode has changed.
Declaration
protected virtual void OnEnvironmentBlendModeChange(int xrEnvironmentBlendMode)
Parameters
Type | Name | Description |
---|---|---|
Int32 | xrEnvironmentBlendMode | New environment blend mode value |
OnFormFactorChange(Int32)
Notification to the feature implementer that the form factor has changed.
Declaration
protected virtual void OnFormFactorChange(int xrFormFactor)
Parameters
Type | Name | Description |
---|---|---|
Int32 | xrFormFactor | New form factor value |
OnInstanceCreate(UInt64)
Called when xrInstance is created.
Declaration
protected virtual bool OnInstanceCreate(ulong xrInstance)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrInstance | Handle of the xrInstance |
Returns
Type | Description |
---|---|
Boolean |
OnInstanceDestroy(UInt64)
Called before xrDestroyInstance
Declaration
protected virtual void OnInstanceDestroy(ulong xrInstance)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrInstance | Handle of the xrInstance |
OnInstanceLossPending(UInt64)
Notification to the feature implementer that the instance is about to be lost. This feature should do what it needs to do to clean up in preparation for termination.
Declaration
protected virtual void OnInstanceLossPending(ulong xrInstance)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrInstance | The instance that is going to be lost |
OnSessionBegin(UInt64)
Called after xrSessionBegin.
Declaration
protected virtual void OnSessionBegin(ulong xrSession)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrSession | Handle of the xrSession |
OnSessionCreate(UInt64)
Called when xrSession is created.
Declaration
protected virtual void OnSessionCreate(ulong xrSession)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrSession | Handle of the xrSession |
OnSessionDestroy(UInt64)
Called before xrDestroySession.
Declaration
protected virtual void OnSessionDestroy(ulong xrSession)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrSession | Handle of the xrSession |
OnSessionEnd(UInt64)
Called before xrEndSession.
Declaration
protected virtual void OnSessionEnd(ulong xrSession)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrSession | Handle of the xrSession |
OnSessionExiting(UInt64)
Called when the runtime sends an Exiting event.
Declaration
protected virtual void OnSessionExiting(ulong xrSession)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrSession | Handle of the xrSession |
OnSessionLossPending(UInt64)
Notification to the feature implementer that the session is about to be lost. This feature should do what it needs to do to prepare for potential session recreation.
Declaration
protected virtual void OnSessionLossPending(ulong xrSession)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrSession | The session that is going to be lost |
OnSessionStateChange(Int32, Int32)
Called when xrSessionState changes.
Declaration
protected virtual void OnSessionStateChange(int oldState, int newState)
Parameters
Type | Name | Description |
---|---|---|
Int32 | oldState | Previous state |
Int32 | newState | New state |
OnSubsystemCreate()
Called after the XR Loader is initialized and has created its subsystems.
Declaration
protected virtual void OnSubsystemCreate()
OnSubsystemDestroy()
Called before the XR loader destroys its subsystems.
Declaration
protected virtual void OnSubsystemDestroy()
OnSubsystemStart()
Called after the XR loader starts its subsystems.
Declaration
protected virtual void OnSubsystemStart()
OnSubsystemStop()
Called before the XR loader stops its subsystems.
Declaration
protected virtual void OnSubsystemStop()
OnSystemChange(UInt64)
Called when xrSystemId is created.
Declaration
protected virtual void OnSystemChange(ulong xrSystem)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | xrSystem | Handle of the xrSystemId |
OnViewConfigurationTypeChange(Int32)
Notification to the feature implementer that the view configuration type has changed.
Declaration
protected virtual void OnViewConfigurationTypeChange(int xrViewConfigurationType)
Parameters
Type | Name | Description |
---|---|---|
Int32 | xrViewConfigurationType | New view configuration type |
PathToString(UInt64)
Converts an XrPath to a string.
Declaration
protected static string PathToString(ulong path)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | path | Path to convert |
Returns
Type | Description |
---|---|
String | String that represents the path, or null if the path is invalid. |
StartSubsystem<T>()
Start a subsystem instance of a given type. Subsystem is assumed to already be loaded from a previous call to CreateSubsystem. Promoted to public for extensions.
Declaration
protected void StartSubsystem<T>()
where T : class, ISubsystem
Type Parameters
Name | Description |
---|---|
T | A subclass of ISubsystem |
StopSubsystem<T>()
Stops a subsystem instance of a given type. Subsystem is assumed to already be loaded from a previous call to CreateSubsystem. Promoted to public for extensions.
Declaration
protected void StopSubsystem<T>()
where T : class, ISubsystem
Type Parameters
Name | Description |
---|---|
T | A subclass of ISubsystem |
StringToPath(String)
Converts a string to an XrPath.
Declaration
protected static ulong StringToPath(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str | String to convert |
Returns
Type | Description |
---|---|
UInt64 | Path of converted string, or XrPath.none if string could not be converted. |