XRServer
Server for AR and VR features.
Server for AR and VR features.
The AR/VR server is the heart of our Advanced and Virtual Reality solution and handles all the processing.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties5
CameraLockedToOriginProperty
public static bool CameraLockedToOrigin { get; set; }If set to true, the scene will be rendered as if the camera is locked to the XROrigin3D.
Note: This doesn't provide a very comfortable experience for users. This setting exists for doing benchmarking or automated testing, where you want to control what is rendered via code.
PrimaryInterfaceProperty
public static XRInterface PrimaryInterface { get; set; }The primary XRInterface currently bound to the XRServer.
SingletonProperty
public static XRServerInstance Singleton { get; }WorldOriginProperty
public static Transform3D WorldOrigin { get; set; }XRServer gameplay origin. The active XROrigin3D publishes its world transform here; direct assignments can be overwritten by it. The setter emits WorldOriginChanged even on repetition. Move the rig origin/body rather than maintaining two independent owners. A pose GetAdjustedTransform excludes this value.
WorldScaleProperty
public static double WorldScale { get; set; }Shared tracking-to-game scale, initially 1. The setter clamps finite values to 0.01…1000 and forwards state to rendering. Validate finiteness before calling: range comparisons do not reject NaN. Changes pose adjustment, not Entity local Scale or stored velocities.
Methods26
AddInterfacevoid
public static void AddInterface(XRInterface @interface);Registers an XRInterface object.
| Name | Type | Default |
|---|---|---|
interface | XRInterface | — |
AddTracker2 overloads
public static void AddTracker(XRPositionalTracker tracker);Registers a non-null object under its current name. Repeating the same reference emits nothing; a different object with the same name replaces the entry and emits TrackerUpdated. A new name emits TrackerAdded. Discovers no device and validates no hardware capabilities. Keep the name stable until removal.
| Name | Type | Default |
|---|---|---|
tracker | XRPositionalTracker | — |
trackerNon-null object with a configured stable name. Removal uses its name, not reference identity.
public static void AddTracker(XRTracker tracker);Registers a non-null object under its current name. Repeating the same reference emits nothing; a different object with the same name replaces the entry and emits TrackerUpdated. A new name emits TrackerAdded. Discovers no device and validates no hardware capabilities. Keep the name stable until removal.
| Name | Type | Default |
|---|---|---|
tracker | XRTracker | — |
trackerNon-null object with a configured stable name. Removal uses its name, not reference identity.
CenterOnHmdvoid
public static void CenterOnHmd(XRServer.RotationMode rotationMode, bool keepHeight);This is an important function to understand correctly. AR and VR platforms all handle positioning slightly differently.
For platforms that do not offer spatial tracking, our origin point (0, 0, 0) is the location of our HMD, but you have little control over the direction the player is facing in the real world.
For platforms that do offer spatial tracking, our origin point depends very much on the system. For OpenVR, our origin point is usually the center of the tracking space, on the ground. For other platforms, it's often the location of the tracking camera.
This method allows you to center your tracker on the location of the HMD. It will take the current location of the HMD and use that to adjust all your tracking data; in essence, realigning the real world to your player's current position in the game world.
For this method to produce usable results, tracking information must be available. This often takes a few frames after starting your game.
You should call this method after a few seconds have passed. For example, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, or when implementing a teleport mechanism.
| Name | Type | Default |
|---|---|---|
rotationMode | XRServer.RotationMode | — |
keepHeight | bool | — |
ClearReferenceFramevoid
public static void ClearReferenceFrame();Resets the reference-frame adjustment to Identity, forwards it to rendering and emits ReferenceFrameChanged. Changes no gameplay origin, scale setting or raw poses. Source-reviewed; real recenter was not tested.
FindInterfaceXRInterface
public static XRInterface FindInterface(string name);Finds an interface by its name. For example, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it.
| Name | Type | Default |
|---|---|---|
name | string | — |
XRInterfaceGetCameraOffsetsReckfell.Collections.Array<Transform3D>
public static Reckfell.Collections.Array<Transform3D> GetCameraOffsets(StringName trackerName);Gets an array of offset transforms for each view for tracker tracker_name. tracker_name must refer to an XRPositionalTracker used as a camera.
Will check our primary interface first, then check each active interface. Returns empty if no interfaces manage this tracker.
| Name | Type | Default |
|---|---|---|
trackerName | StringName | — |
Reckfell.Collections.Array<Transform3D>GetCameraProjectionsReckfell.Collections.Array<Projection>
public static Reckfell.Collections.Array<Projection> GetCameraProjections(StringName trackerName, double aspect, double near, double far);Gets an array of projection matrices for each view for tracker tracker_name. tracker_name must refer to an XRPositionalTracker used as a camera.
Will check our primary interface first, then check each active interface. Returns empty if no interfaces manage this tracker.
| Name | Type | Default |
|---|---|---|
trackerName | StringName | — |
aspect | double | — |
near | double | — |
far | double | — |
Reckfell.Collections.Array<Projection>GetHmdTransformTransform3D
public static Transform3D GetHmdTransform();Returns the primary interface's transformation.
Transform3DGetInterfaceXRInterface
public static XRInterface GetInterface(int idx);Returns the interface registered at the given idx index in the list of interfaces.
| Name | Type | Default |
|---|---|---|
idx | int | — |
XRInterfaceGetInterfaceCountint
public static int GetInterfaceCount();Returns the number of interfaces currently registered with the AR/VR server. If your project supports multiple AR/VR platforms, you can look through the available interface, and either present the user with a selection or simply try to initialize each interface and use the first one that returns true.
intGetInterfacesReckfell.Collections.Array<Reckfell.Collections.Dictionary>
public static Reckfell.Collections.Array<Reckfell.Collections.Dictionary> GetInterfaces();Returns a list of available interfaces the ID and name of each interface.
Reckfell.Collections.Array<Reckfell.Collections.Dictionary>GetPrimaryInterfaceXRInterface
public static XRInterface GetPrimaryInterface();XRInterfaceGetReferenceFrameTransform3D
public static Transform3D GetReferenceFrame();Copy of the tracking-space adjustment. GetAdjustedTransform left-multiplies by it after position scaling. Not gameplay WorldOrigin. Only Identity was tested here; recenter needs separate device verification.
Transform3DTracking-space adjustment, not gameplay origin.
GetTrackerXRTracker
public static XRTracker GetTracker(StringName trackerName);Returns a registered XRTracker by exact name, or null. Includes nonpositional trackers omitted by current GetTrackers. The object is shared: do not dispose its borrowed C# wrapper or edit provider-owned data.
| Name | Type | Default |
|---|---|---|
trackerName | StringName | — |
trackerNameExact XRServer entry name, not ResourceName or a numeric ID.
XRTrackerShared registered XRTracker or null; do not dispose the borrowed object.
GetTrackersReckfell.Collections.Dictionary
public static Reckfell.Collections.Dictionary GetTrackers(int trackerTypes);Returns a separate Dictionary: names as keys, shared tracker objects as values. Clearing the container unregisters nothing. The mask is bit-tested against Type. Confirmed defect: implementation first casts objects to XRPositionalTracker, so even Any omits nonpositional XRFaceTracker. Use GetTracker for a known name; do not treat this list as complete.
| Name | Type | Default |
|---|---|---|
trackerTypes | int | — |
trackerTypesBitwise int mask of XRServer.TrackerType. Even Any currently omits nonpositional trackers.
Reckfell.Collections.DictionarySeparate Dictionary of shared positional trackers; current enumeration is incomplete for Any.
GetWorldOriginTransform3D
public static Transform3D GetWorldOrigin();Copy of the current server gameplay origin, not raw head pose. The render thread reads render-frame state.
Transform3DCopy of gameplay origin maintained by the active XROrigin3D.
GetWorldScaledouble
public static double GetWorldScale();Returns the shared scale as double. The render thread reads its stored render state; the main thread reads current server state. Thread synchronization was not checked here.
doubleShared XRServer scale; not Entity Scale.
IsCameraLockedToOriginbool
public static bool IsCameraLockedToOrigin();boolRemoveInterfacevoid
public static void RemoveInterface(XRInterface @interface);Removes this interface.
| Name | Type | Default |
|---|---|---|
interface | XRInterface | — |
RemoveTracker2 overloads
public static void RemoveTracker(XRPositionalTracker tracker);Removes the entry by the supplied object’s current name, not reference identity. After replacement, an old reference with the same name can remove the new tracker. TrackerRemoved fires before erasure; GetTracker can still return the entry inside the handler. Destroys no external references and synthesizes no button releases.
| Name | Type | Default |
|---|---|---|
tracker | XRPositionalTracker | — |
trackerNon-null object with a configured stable name. Removal uses its name, not reference identity.
public static void RemoveTracker(XRTracker tracker);Removes the entry by the supplied object’s current name, not reference identity. After replacement, an old reference with the same name can remove the new tracker. TrackerRemoved fires before erasure; GetTracker can still return the entry inside the handler. Destroys no external references and synthesizes no button releases.
| Name | Type | Default |
|---|---|---|
tracker | XRTracker | — |
trackerNon-null object with a configured stable name. Removal uses its name, not reference identity.
SetCameraLockedToOriginvoid
public static void SetCameraLockedToOrigin(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetPrimaryInterfacevoid
public static void SetPrimaryInterface(XRInterface @interface);| Name | Type | Default |
|---|---|---|
interface | XRInterface | — |
SetWorldOriginvoid
public static void SetWorldOrigin(Transform3D worldOrigin);XRServer gameplay origin. The active XROrigin3D publishes its world transform here; direct assignments can be overwritten by it. The setter emits WorldOriginChanged even on repetition. Move the rig origin/body rather than maintaining two independent owners. A pose GetAdjustedTransform excludes this value.
| Name | Type | Default |
|---|---|---|
worldOrigin | Transform3D | — |
worldOriginGameplay origin transform; an active XROrigin3D can overwrite it.
SetWorldScalevoid
public static void SetWorldScale(double scale);Shared tracking-to-game scale, initially 1. The setter clamps finite values to 0.01…1000 and forwards state to rendering. Validate finiteness before calling: range comparisons do not reject NaN. Changes pose adjustment, not Entity local Scale or stored velocities.
| Name | Type | Default |
|---|---|---|
scale | double | — |
scalePositive finite double scale; pass neither NaN nor infinity.
Signals and events7
InterfaceAddedEvent
public static event XRServer.InterfaceAddedEventHandler InterfaceAdded;Emitted when a new interface has been added.
| Name | Type | Default |
|---|---|---|
interfaceName | StringName | — |
InterfaceRemovedEvent
public static event XRServer.InterfaceRemovedEventHandler InterfaceRemoved;Emitted when an interface is removed.
| Name | Type | Default |
|---|---|---|
interfaceName | StringName | — |
ReferenceFrameChangedEvent
public static event Action ReferenceFrameChanged;Emitted when the reference frame transform changes.
TrackerAddedEvent
public static event XRServer.TrackerAddedEventHandler TrackerAdded;A new-entry event emitted after insertion. Carries the name and numeric long category, not the object. Provider registration, not proof of a current pose or hardware connection.
| Name | Type | Default |
|---|---|---|
trackerName | StringName | — |
type | long | — |
trackerNameExact XRServer entry name, not ResourceName or a numeric ID.
typeNumeric long category from XRServer.TrackerType, not a tracker object.
TrackerRemovedEvent
public static event XRServer.TrackerRemovedEventHandler TrackerRemoved;Emitted before registry erasure. Lookup by name may still return the object in the handler; this does not mean removal was cancelled. After RemoveTracker returns the entry is absent.
| Name | Type | Default |
|---|---|---|
trackerName | StringName | — |
type | long | — |
trackerNameExact XRServer entry name, not ResourceName or a numeric ID.
typeNumeric long category from XRServer.TrackerType, not a tracker object.
TrackerUpdatedEvent
public static event XRServer.TrackerUpdatedEventHandler TrackerUpdated;Emitted when another object replaces the entry under the same name. Repeating AddTracker with the same reference does not emit it. Not a per-tracking-frame event; pose updates are separate.
| Name | Type | Default |
|---|---|---|
trackerName | StringName | — |
type | long | — |
trackerNameExact XRServer entry name, not ResourceName or a numeric ID.
typeNumeric long category from XRServer.TrackerType, not a tracker object.
WorldOriginChangedEvent
public static event Action WorldOriginChanged;Emitted when the world origin transform changes.
XRServer.RotationMode
| Value | Description |
|---|---|
DontResetRotation = 2 | Does not reset the orientation of the HMD, only the position of the player gets centered. |
ResetButKeepTilt = 1 | Resets the orientation but keeps the tilt of the device. So if we're looking down, we keep looking down but heading will be reset. |
ResetFullRotation = 0 | Fully reset the orientation of the HMD. Regardless of what direction the user is looking to in the real world. The user will look dead ahead in the virtual world. |
XRServer.TrackerType
| Value | Description |
|---|---|
Anchor = 8 | The tracker tracks the location and size of an AR anchor. |
Any = 255 | Used internally to select all trackers. |
AnyKnown = 127 | Used internally to filter trackers of any known type. |
Basestation = 4 | The tracker tracks the location of a base station. |
Body = 32 | The tracker tracks the location and joints of a body. |
Camera = 1 | The tracker tracks the position of an XR camera (HMD, external camera, phone camera for phone based AR). |
Controller = 2 | The tracker tracks the location of a controller. |
Face = 64 | The tracker tracks the expressions of a face. |
Hand = 16 | The tracker tracks the location and joints of a hand. |
Head = 1 | The tracker tracks the location of the player's head. This is usually a location centered between the player's eyes. Note that for handheld AR devices this can be the current location of the device. |
Unknown = 128 | Used internally if we haven't set the tracker type yet. |