WebXRInterface
Browser XR: sessions, features, input and events.
Abstract browser WebXR API: session modes, features, input and events. The concrete registered interface named WebXR is created in a Web build. SDK-type availability in a desktop editor does not start browser XR. Current C# exporter 1.0.0 does not implement the Web target; this reference promises no C# Web export.
Subscribe before requesting. IsSessionSupported asynchronously reports through SessionSupported; it grants no permission and starts no XR session. Initialize sets initialized before request completion; wait for SessionStarted before enabling Viewport.UseXR. Restore prior UI/viewport on SessionEnded/SessionFailed. Use the borrowed registered interface without manually freeing it.
Apply settings before startup. RequestedReferenceSpaceTypes defines fallback order; ReferenceSpaceType reports the actual selection. EnabledFeatures may be empty if the browser provides no list. Input depends on source activity and pose data. Current code emits Select/Squeeze after the corresponding end event: avoid duplicate gameplay actions.
GetDisplayRefreshRate is not FPS. Rate requests are asynchronous; current JS does not convert rejected support/refresh promises into SessionFailed. Provide observable pending/error state. Rate functions use integer JS ABI; fractional values across WASM were not tested.
WebXR startup and diagnosis. JS function bodies were executed with mock browser/session/GL in Node; native callbacks, actual export, permissions, headset, input and pixels are not accepted as tested. Engine source and build were unchanged.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties8
DisableWebxrLayersProperty
public bool DisableWebxrLayers { get; set; }Stored WebXR Layers disable flag, initially false. Set before Initialize; true selects XRWebGLLayer fallback. Actual fallback can occur even at false because multiview/binding/createProjectionLayer is unavailable. The getter reports neither the selected rendering path nor a quality level.
EnabledFeaturesProperty
public string EnabledFeatures { get; }Browser-reported accepted features as a comma-separated string after SessionStarted. Not a copy of RequiredFeatures/OptionalFeatures. If the browser provides no enabledFeatures property, JS reports an empty string, which does not prove all capabilities absent. Uninitialize clears it.
OptionalFeaturesProperty
public string OptionalFeatures { get; set; }Comma-separated optional-feature string, initially empty. Used for the next session request; the setter only stores it. Missing optional functionality must not break the baseline workflow: check EnabledFeatures after SessionStarted, not merely this request list.
ReferenceSpaceTypeProperty
public string ReferenceSpaceType { get; }Actual selected reference space after SessionStarted, not the first requested string. May be empty before readiness; Uninitialize clears it. If local was selected, do not treat Y=0 as the physical floor.
RequestedReferenceSpaceTypesProperty
public string RequestedReferenceSpaceTypes { get; set; }Comma-separated reference-space list in attempt order, initially local. For example local-floor,local: fallback to local changes height semantics and establishes no floor. Request required features separately. An entirely empty string causes early Initialize failure; avoid empty list elements.
RequiredFeaturesProperty
public string RequiredFeatures { get; set; }Comma-separated required-feature string, initially empty. Before Initialize request only necessary features, for example local-floor. JS trims whitespace and removes empty entries. An unsupported required feature can reject startup; the stored string establishes no permission.
SessionModeProperty
public string SessionMode { get; set; }Requested session mode: inline, immersive-vr or immersive-ar; initially inline. The setter stores a string for startup, without checking support or switching a running session. Query the intended mode separately with IsSessionSupported.
VisibilityStateProperty
public string VisibilityState { get; }Current session browser visibilityState: typically visible, visible-blurred or hidden; empty string without a session/value. XR-session visibility is neither geometry readiness nor a device HasTrackingData flag. Read again on VisibilityStateChanged.
Methods20
GetAvailableDisplayRefreshRatesReckfell.Collections.Array
public Reckfell.Collections.Array GetAvailableDisplayRefreshRates();Returns a fresh array container copied from browser supportedFrameRates; empty without session, property or entries. Does not measure performance or guarantee every request is accepted now. Dispose/use using for the owned Array container; it owns no XR device.
Reckfell.Collections.ArrayFresh Array of rates, possibly empty. The caller owns the container.
GetDisableWebxrLayersbool
public bool GetDisableWebxrLayers();Returns the stored value. Stored WebXR Layers disable flag, initially false. Set before Initialize; true selects XRWebGLLayer fallback. Actual fallback can occur even at false because multiview/binding/createProjectionLayer is unavailable. The getter reports neither the selected rendering path nor a quality level.
boolStored WebXR Layers disable flag, initially false. Set before Initialize; true selects XRWebGLLayer fallback. Actual fallback can occur even at false because multiview/binding/createProjectionLayer is unavailable. The getter reports neither the selected rendering path nor a quality level.
GetDisplayRefreshRatefloat
public float GetDisplayRefreshRate();Reads browser session.frameRate; 0 if session or property is absent. Neither measured application FPS nor stored target rate. The JS function declares an integer ABI; fractional values across the real WASM boundary were not tested here.
floatBrowser-reported rate, or 0 if unavailable; not application FPS.
GetEnabledFeaturesstring
public string GetEnabledFeatures();Reads the current value. Browser-reported accepted features as a comma-separated string after SessionStarted. Not a copy of RequiredFeatures/OptionalFeatures. If the browser provides no enabledFeatures property, JS reports an empty string, which does not prove all capabilities absent. Uninitialize clears it.
stringBrowser-reported accepted features as a comma-separated string after SessionStarted. Not a copy of RequiredFeatures/OptionalFeatures. If the browser provides no enabledFeatures property, JS reports an empty string, which does not prove all capabilities absent. Uninitialize clears it.
GetInputSourceTargetRayModeWebXRInterface.TargetRayMode
public WebXRInterface.TargetRayMode GetInputSourceTargetRayMode(int inputSourceId);Returns an active slot’s ray mode: Gaze, TrackedPointer or Screen. Unknown for inactive/invalid slots; an invalid index also emits a native error. Ray mode establishes neither grip, buttons nor a hand skeleton.
| Name | Type | Default |
|---|---|---|
inputSourceId | int | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
WebXRInterface.TargetRayModeActive source’s mode or Unknown; not proof of a physical controller.
GetInputSourceTrackerXRControllerTracker
public XRControllerTracker GetInputSourceTracker(int inputSourceId);Returns the slot’s borrowed XRControllerTracker or null. Check activity and the required pose data; do not Free/Dispose the provider-owned wrapper. Slots and trackers may disappear or be reused; do not retain them as permanent device identity.
| Name | Type | Default |
|---|---|---|
inputSourceId | int | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
XRControllerTrackerBorrowed tracker or null; ownership is not transferred.
GetOptionalFeaturesstring
public string GetOptionalFeatures();Returns the stored value. Comma-separated optional-feature string, initially empty. Used for the next session request; the setter only stores it. Missing optional functionality must not break the baseline workflow: check EnabledFeatures after SessionStarted, not merely this request list.
stringComma-separated optional-feature string, initially empty. Used for the next session request; the setter only stores it. Missing optional functionality must not break the baseline workflow: check EnabledFeatures after SessionStarted, not merely this request list.
GetReferenceSpaceTypestring
public string GetReferenceSpaceType();Reads the current value. Actual selected reference space after SessionStarted, not the first requested string. May be empty before readiness; Uninitialize clears it. If local was selected, do not treat Y=0 as the physical floor.
stringActual selected reference space after SessionStarted, not the first requested string. May be empty before readiness; Uninitialize clears it. If local was selected, do not treat Y=0 as the physical floor.
GetRequestedReferenceSpaceTypesstring
public string GetRequestedReferenceSpaceTypes();Returns the stored value. Comma-separated reference-space list in attempt order, initially local. For example local-floor,local: fallback to local changes height semantics and establishes no floor. Request required features separately. An entirely empty string causes early Initialize failure; avoid empty list elements.
stringComma-separated reference-space list in attempt order, initially local. For example local-floor,local: fallback to local changes height semantics and establishes no floor. Request required features separately. An entirely empty string causes early Initialize failure; avoid empty list elements.
GetRequiredFeaturesstring
public string GetRequiredFeatures();Returns the stored value. Comma-separated required-feature string, initially empty. Before Initialize request only necessary features, for example local-floor. JS trims whitespace and removes empty entries. An unsupported required feature can reject startup; the stored string establishes no permission.
stringComma-separated required-feature string, initially empty. Before Initialize request only necessary features, for example local-floor. JS trims whitespace and removes empty entries. An unsupported required feature can reject startup; the stored string establishes no permission.
GetSessionModestring
public string GetSessionMode();Returns the stored value. Requested session mode: inline, immersive-vr or immersive-ar; initially inline. The setter stores a string for startup, without checking support or switching a running session. Query the intended mode separately with IsSessionSupported.
stringRequested session mode: inline, immersive-vr or immersive-ar; initially inline. The setter stores a string for startup, without checking support or switching a running session. Query the intended mode separately with IsSessionSupported.
GetVisibilityStatestring
public string GetVisibilityState();Reads the current value. Current session browser visibilityState: typically visible, visible-blurred or hidden; empty string without a session/value. XR-session visibility is neither geometry readiness nor a device HasTrackingData flag. Read again on VisibilityStateChanged.
stringCurrent session browser visibilityState: typically visible, visible-blurred or hidden; empty string without a session/value. XR-session visibility is neither geometry readiness nor a device HasTrackingData flag. Read again on VisibilityStateChanged.
IsInputSourceActivebool
public bool IsInputSourceActive(int inputSourceId);Reads activity of a WebXR input-source slot. Valid IDs are 0–15; an invalid index emits a native error and returns false. True guarantees neither a grip pose, physical controller nor every button. Not a gamepad index.
| Name | Type | Default |
|---|---|---|
inputSourceId | int | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
boolCurrent slot activity; invalid index returns false with a native error.
IsSessionSupportedvoid
public void IsSessionSupported(string sessionMode);Asynchronously queries support for the specified mode; returns no boolean and starts no session. Subscribe to SessionSupported first and match the response sessionMode. Current JS has no rejected-promise handler: provide a pending-query timeout without treating it as confirmed false.
| Name | Type | Default |
|---|---|---|
sessionMode | string | — |
sessionModeMode inline, immersive-vr or immersive-ar. Support and permission are mode-specific.
SetDisableWebxrLayersvoid
public void SetDisableWebxrLayers(bool disable);Stores configuration without recreating a running browser session. Stored WebXR Layers disable flag, initially false. Set before Initialize; true selects XRWebGLLayer fallback. Actual fallback can occur even at false because multiview/binding/createProjectionLayer is unavailable. The getter reports neither the selected rendering path nor a quality level.
| Name | Type | Default |
|---|---|---|
disable | bool | — |
disableStored WebXR Layers disable flag, initially false. Set before Initialize; true selects XRWebGLLayer fallback. Actual fallback can occur even at false because multiview/binding/createProjectionLayer is unavailable. The getter reports neither the selected rendering path nor a quality level.
SetDisplayRefreshRatevoid
public void SetDisplayRefreshRate(float refreshRate);Asynchronously requests session.updateTargetFrameRate. Silently does nothing without a session or method. Choose a listed available rate; application is not guaranteed. A resolved promise triggers DisplayRefreshRateChanged. Current bridge has no rejection handler or dedicated request-failure event.
| Name | Type | Default |
|---|---|---|
refreshRate | float | — |
refreshRateRequested device-listed frequency in Hz, not desired game FPS. Current JS parameter ABI is integer; fractional rates through WASM were not tested here.
SetOptionalFeaturesvoid
public void SetOptionalFeatures(string optionalFeatures);Stores configuration without recreating a running browser session. Comma-separated optional-feature string, initially empty. Used for the next session request; the setter only stores it. Missing optional functionality must not break the baseline workflow: check EnabledFeatures after SessionStarted, not merely this request list.
| Name | Type | Default |
|---|---|---|
optionalFeatures | string | — |
optionalFeaturesComma-separated optional-feature string, initially empty. Used for the next session request; the setter only stores it. Missing optional functionality must not break the baseline workflow: check EnabledFeatures after SessionStarted, not merely this request list.
SetRequestedReferenceSpaceTypesvoid
public void SetRequestedReferenceSpaceTypes(string requestedReferenceSpaceTypes);Stores configuration without recreating a running browser session. Comma-separated reference-space list in attempt order, initially local. For example local-floor,local: fallback to local changes height semantics and establishes no floor. Request required features separately. An entirely empty string causes early Initialize failure; avoid empty list elements.
| Name | Type | Default |
|---|---|---|
requestedReferenceSpaceTypes | string | — |
requestedReferenceSpaceTypesComma-separated reference-space list in attempt order, initially local. For example local-floor,local: fallback to local changes height semantics and establishes no floor. Request required features separately. An entirely empty string causes early Initialize failure; avoid empty list elements.
SetRequiredFeaturesvoid
public void SetRequiredFeatures(string requiredFeatures);Stores configuration without recreating a running browser session. Comma-separated required-feature string, initially empty. Before Initialize request only necessary features, for example local-floor. JS trims whitespace and removes empty entries. An unsupported required feature can reject startup; the stored string establishes no permission.
| Name | Type | Default |
|---|---|---|
requiredFeatures | string | — |
requiredFeaturesComma-separated required-feature string, initially empty. Before Initialize request only necessary features, for example local-floor. JS trims whitespace and removes empty entries. An unsupported required feature can reject startup; the stored string establishes no permission.
SetSessionModevoid
public void SetSessionMode(string sessionMode);Stores configuration without recreating a running browser session. Requested session mode: inline, immersive-vr or immersive-ar; initially inline. The setter stores a string for startup, without checking support or switching a running session. Query the intended mode separately with IsSessionSupported.
| Name | Type | Default |
|---|---|---|
sessionMode | string | — |
sessionModeMode inline, immersive-vr or immersive-ar. Support and permission are mode-specific.
Signals and events13
DisplayRefreshRateChangedEvent
public event Action DisplayRefreshRateChanged;Parameterless notification after a resolved updateTargetFrameRate promise. Read GetDisplayRefreshRate again; neither a frame event nor an FPS counter. Missing method means the request is ignored; a rejected promise is not converted into SessionFailed.
ReferenceSpaceResetEvent
public event Action ReferenceSpaceReset;Parameterless reset notification from the selected reference space. Reassess gameplay-world bindings; this event does not forward the original browser transform. Do not automatically apply another recenter over the configured origin.
SelectEvent
public event WebXRInterface.SelectEventHandler Select;Completion of the source’s primary selection action, synthesized by current native code immediately after Selectend. Not a separately forwarded browser event or hold start. Choose one completion event for a one-shot gameplay operation.
| Name | Type | Default |
|---|---|---|
inputSourceId | long | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
SelectendEvent
public event WebXRInterface.SelectendEventHandler Selectend;End of the source’s primary selection action; current native code then separately emits Select. Do not handle both as two independent purchases/shots.
| Name | Type | Default |
|---|---|---|
inputSourceId | long | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
SelectstartEvent
public event WebXRInterface.SelectstartEventHandler Selectstart;Start of the source’s primary selection action. Native code updates the input source before notification. Does not establish a trigger/grip button on every device; use the supplied ID and ray mode.
| Name | Type | Default |
|---|---|---|
inputSourceId | long | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
SessionEndedEvent
public event Action SessionEnded;Browser-end notification after native Uninitialize. Restore the previous Viewport.UseXR, ordinary UI and owned state. Do not assume every direct Uninitialize call must synchronously emit it; avoid an automatic restart loop.
SessionFailedEvent
public event WebXRInterface.SessionFailedEventHandler SessionFailed;Early-validation or asynchronous-startup failure with a reason string. Early failure can occur within Initialize; the browser-failure callback uninitializes first. Restore UI/viewport and retain message. Not a universal error event: current bridge does not handle rejected support/refresh promises.
| Name | Type | Default |
|---|---|---|
message | string | — |
messageStartup-failure reason. Retain for diagnosis and present a useful result; do not replace it with an unsupported claim that no headset exists.
SessionStartedEvent
public event Action SessionStarted;Emitted after browser-session creation, GL setup and reference-space acquisition. Read ReferenceSpaceType/EnabledFeatures and enable Viewport.UseXR afterward. Do not substitute Initialize=true: initialized is set earlier. The event establishes neither pixel quality nor controllers.
SessionSupportedEvent
public event WebXRInterface.SessionSupportedEventHandler SessionSupported;IsSessionSupported result: mode and support boolean. Neither startup permission, required-feature validation nor assurance of successful Initialize. Without navigator.xr the bridge reports false; a rejected browser promise may currently produce no event.
| Name | Type | Default |
|---|---|---|
sessionMode | string | — |
supported | bool | — |
sessionModeMode inline, immersive-vr or immersive-ar. Support and permission are mode-specific.
supportedMode-support result; true establishes neither user permission nor required features for a future request.
SqueezeEvent
public event WebXRInterface.SqueezeEventHandler Squeeze;Completion of the source’s squeeze action, synthesized by current native code immediately after Squeezeend. Not a separately forwarded browser event or hold start. Choose one completion event for a one-shot gameplay operation.
| Name | Type | Default |
|---|---|---|
inputSourceId | long | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
SqueezeendEvent
public event WebXRInterface.SqueezeendEventHandler Squeezeend;End of the source’s squeeze action; current native code then separately emits Squeeze. Do not handle both as two independent purchases/shots.
| Name | Type | Default |
|---|---|---|
inputSourceId | long | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
SqueezestartEvent
public event WebXRInterface.SqueezestartEventHandler Squeezestart;Start of the source’s squeeze action. Native code updates the input source before notification. Does not establish a trigger/grip button on every device; use the supplied ID and ray mode.
| Name | Type | Default |
|---|---|---|
inputSourceId | long | — |
inputSourceIdWebXR slot ID in 0–15. A transient source, not a gamepad index or permanent device ID; check activity and tracking data.
VisibilityStateChangedEvent
public event Action VisibilityStateChanged;Parameterless browser visibilitychange notification. Read VisibilityState and apply your game’s pause/UI policy. Does not mean session end, model availability or restored tracking.
WebXRInterface.TargetRayMode
| Value | Description |
|---|---|
Gaze = 1 | Target ray originates at the viewer's eyes and points in the direction they are looking. |
Screen = 3 | Target ray from touch screen, mouse or other tactile input device. |
TrackedPointer = 2 | Target ray from a handheld pointer, most likely a VR touch controller. |
Unknown = 0 | We don't know the target ray mode. |