Class MockRuntime
OpenXR Mock Runtime
Inherited Members
Namespace: UnityEngine.XR.OpenXR.Features.Mock
Assembly: solution.dll
Syntax
public class MockRuntime : OpenXRFeature
Fields
featureId
The feature id string. This is used to give the feature a well known id for reference.
Declaration
public const string featureId = "com.unity.openxr.feature.mockruntime"
Field Value
| Type | Description |
|---|---|
| string |
ignoreValidationErrors
Don't fail to build if there are validation errors.
Declaration
public bool ignoreValidationErrors
Field Value
| Type | Description |
|---|---|
| bool |
Properties
Instance
Return the singleton instance of the Mock Runtime feature.
Declaration
public static MockRuntime Instance { get; }
Property Value
| Type | Description |
|---|---|
| MockRuntime |
Methods
CauseInstanceLoss()
Force MockRuntime instance loss.
Declaration
public static extern void CauseInstanceLoss()
ClearFunctionCallbacks()
Remove all OpenXR function callbacks
Declaration
public static void ClearFunctionCallbacks()
GetAfterFunctionCallback(string)
Return the callback set to be called after the given OpenXR function is called
Declaration
public static MockRuntime.AfterFunctionDelegate GetAfterFunctionCallback(string function)
Parameters
| Type | Name | Description |
|---|---|---|
| string | function | OpenXR function name |
Returns
| Type | Description |
|---|---|
| MockRuntime.AfterFunctionDelegate | Callback or null if no callback is set |
GetBeforeFunctionCallback(string)
Return the callback set to be called before the given OpenXR function is called
Declaration
public static MockRuntime.BeforeFunctionDelegate GetBeforeFunctionCallback(string function)
Parameters
| Type | Name | Description |
|---|---|---|
| string | function | OpenXR function name |
Returns
| Type | Description |
|---|---|
| MockRuntime.BeforeFunctionDelegate | Callback or null if no callback is set |
HookCreateInstance(IntPtr)
Called to hook xrGetInstanceProcAddr.
Declaration
public static extern IntPtr HookCreateInstance(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 XR native functions. |
OnInstanceDestroy(ulong)
Called before xrDestroyInstance
Declaration
protected override void OnInstanceDestroy(ulong instance)
Parameters
| Type | Name | Description |
|---|---|---|
| ulong | instance |
Overrides
RequestExitSession()
Request to exit the runtime session.
Declaration
public static extern void RequestExitSession()
ResetDefaults()
Reset the MockRuntime testing settings back to defaults
Declaration
public static void ResetDefaults()
SetFunctionCallback(string, AfterFunctionDelegate)
Set a callback to call before the given OpenXR function is called within the Mock Runtime
Declaration
public static void SetFunctionCallback(string function, MockRuntime.AfterFunctionDelegate afterCallback)
Parameters
| Type | Name | Description |
|---|---|---|
| string | function | OpenXR function name |
| MockRuntime.AfterFunctionDelegate | afterCallback | Callback to call after the OpenXR function is called (null to clear) |
SetFunctionCallback(string, BeforeFunctionDelegate)
Set a callback to call before the given OpenXR function is called within the Mock Runtime
Note that since some OpenXR functions are called from within the graphics thread that care should be taken to maintain thread safety from within the callbacks.
Note that function callbacks can be set prior to the MockRuntime being initialized but will be reset when the mock runtime is shutdown.
Declaration
public static void SetFunctionCallback(string function, MockRuntime.BeforeFunctionDelegate beforeCallback)
Parameters
| Type | Name | Description |
|---|---|---|
| string | function | OpenXR function name |
| MockRuntime.BeforeFunctionDelegate | beforeCallback | Callback to call before the OpenXR function is called (null to clear) |
SetFunctionCallback(string, BeforeFunctionDelegate, AfterFunctionDelegate)
Set the callbacks to call before and after the given OpenXR function is called within the Mock Runtime
Note that since some OpenXR functions are called from within the graphics thread that care should be taken to maintain thread safety from within the callbacks.
Note that function callbacks can be set prior to the MockRuntime being initialized but will be reset when the mock runtime is shutdown.
Declaration
public static void SetFunctionCallback(string function, MockRuntime.BeforeFunctionDelegate beforeCallback, MockRuntime.AfterFunctionDelegate afterCallback)
Parameters
| Type | Name | Description |
|---|---|---|
| string | function | OpenXR function name |
| MockRuntime.BeforeFunctionDelegate | beforeCallback | Callback to call before the OpenXR function is called (null to clear) |
| MockRuntime.AfterFunctionDelegate | afterCallback | Callback to call after the OpenXR function is called (null to clear) |
SetKeepFunctionCallbacks(bool)
Keep function callbacks when resetting MockRuntime.
Declaration
public static extern void SetKeepFunctionCallbacks(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | True to keep callbacks. |
SetSpace(ulong, Vector3, Quaternion, XrSpaceLocationFlags)
Set the reference space to use for input actions.
Declaration
public static extern void SetSpace(ulong actionHandle, Vector3 position, Quaternion orientation, XrSpaceLocationFlags locationFlags)
Parameters
| Type | Name | Description |
|---|---|---|
| ulong | actionHandle | Handle to the input action. |
| Vector3 | position | Position of the space. |
| Quaternion | orientation | Orientation of the space. |
| XrSpaceLocationFlags | locationFlags | XrSpaceLocationFlags for the space. |
SetSpace(XrReferenceSpaceType, Vector3, Quaternion, XrSpaceLocationFlags)
Set the reference space to use at Runtime.
Declaration
public static extern void SetSpace(XrReferenceSpaceType referenceSpace, Vector3 position, Quaternion orientation, XrSpaceLocationFlags locationFlags)
Parameters
| Type | Name | Description |
|---|---|---|
| XrReferenceSpaceType | referenceSpace | The type of reference space being set. |
| Vector3 | position | Position of the space. |
| Quaternion | orientation | Orientation of the space. |
| XrSpaceLocationFlags | locationFlags | XrSpaceLocationFlags for the space. |
SetViewPose(XrViewConfigurationType, int, Vector3, Quaternion, Vector4)
Set the runtime ViewPose.
Declaration
public static extern void SetViewPose(XrViewConfigurationType viewConfigurationType, int viewIndex, Vector3 position, Quaternion orientation, Vector4 fov)
Parameters
| Type | Name | Description |
|---|---|---|
| XrViewConfigurationType | viewConfigurationType | The XrViewConfigurationType to use. |
| int | viewIndex | The indexed view being set. |
| Vector3 | position | Position of the view. |
| Quaternion | orientation | Orientation of the view. |
| Vector4 | fov | Field of View. |
SetViewState(XrViewConfigurationType, XrViewStateFlags)
Set the runtime ViewState.
Declaration
public static extern void SetViewState(XrViewConfigurationType viewConfigurationType, XrViewStateFlags viewStateFlags)
Parameters
| Type | Name | Description |
|---|---|---|
| XrViewConfigurationType | viewConfigurationType | The XrViewConfigurationType to use. |
| XrViewStateFlags | viewStateFlags | The XrViewStateFlags to set. |
Events
onScriptEvent
Subscribe delegates to ScriptEvents.
Declaration
public static event MockRuntime.ScriptEventDelegate onScriptEvent
Event Type
| Type | Description |
|---|---|
| MockRuntime.ScriptEventDelegate |