Class XRRig
The XR Rig component is typically attached to the base object of the XR Rig,
and stores the
Namespace: UnityEngine.XR.Interaction.Toolkit
Syntax
public class XRRig : MonoBehaviour
Properties
cameraFloorOffsetObject
The
Declaration
public GameObject cameraFloorOffsetObject { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
cameraGameObject
The
Declaration
public GameObject cameraGameObject { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
cameraInRigSpaceHeight
(Read Only) The camera's height relative to the rig.
Declaration
public float cameraInRigSpaceHeight { get; }
Property Value
Type | Description |
---|---|
Single |
cameraInRigSpacePos
(Read Only) The camera's local position in rig space.
Declaration
public Vector3 cameraInRigSpacePos { get; }
Property Value
Type | Description |
---|---|
Vector3 |
cameraYOffset
Camera height to be used when in Device
Tracking Origin Mode to define the height of the user from the floor.
This is the amount that the camera is offset from the floor when moving the cameraFloorOffsetObject.
Declaration
public float cameraYOffset { get; set; }
Property Value
Type | Description |
---|---|
Single |
currentTrackingOriginMode
(Read Only) The Tracking Origin Mode that this Rig is in.
Declaration
public TrackingOriginModeFlags currentTrackingOriginMode { get; }
Property Value
Type | Description |
---|---|
TrackingOriginModeFlags |
See Also
requestedTrackingOriginMode
The type of tracking origin to use for this Rig. Tracking origins identify where (0, 0, 0) is in the world of tracking. Not all devices support all tracking origin modes.
Declaration
public XRRig.TrackingOriginMode requestedTrackingOriginMode { get; set; }
Property Value
Type | Description |
---|---|
XRRig.TrackingOriginMode |
See Also
rig
The "Rig"
Declaration
public GameObject rig { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
rigInCameraSpacePos
(Read Only) The rig's local position in camera space.
Declaration
public Vector3 rigInCameraSpacePos { get; }
Property Value
Type | Description |
---|---|
Vector3 |
trackingOriginMode
The type of tracking origin to use for this Rig. Tracking origins identify where (0, 0, 0) is in the world of tracking. Not all devices support all tracking spaces.
Declaration
public TrackingOriginModeFlags trackingOriginMode { get; set; }
Property Value
Type | Description |
---|---|
TrackingOriginModeFlags |
trackingSpace
Whether the experience is Room Scale or Stationary. Not all devices support all tracking spaces; if the selected tracking space is not set it will fall back to Stationary.
Declaration
public TrackingSpaceType trackingSpace { get; set; }
Property Value
Type | Description |
---|---|
TrackingSpaceType |
Methods
Awake()
See
Declaration
protected void Awake()
MatchRigUp(Vector3)
This function will rotate the rig object such that the rig's up vector will match the provided vector.
Declaration
public bool MatchRigUp(Vector3 destinationUp)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | destinationUp | the vector to which the rig object's up vector will be matched. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the rotation is performed or the vectors have already been matched. Otherwise, returns false. |
MatchRigUpCameraForward(Vector3, Vector3)
This function will rotate the rig object around the camera object using the destinationUp
vector such that:
Declaration
public bool MatchRigUpCameraForward(Vector3 destinationUp, Vector3 destinationForward)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | destinationUp | The up vector that the rig's up vector will be matched to. |
Vector3 | destinationForward | The forward vector that will be matched to the projection of the camera's forward vector on the plane with the normal |
Returns
Type | Description |
---|---|
Boolean | Returns true if the rotation is performed. Otherwise, returns false. |
MatchRigUpRigForward(Vector3, Vector3)
This function will rotate the rig object around the camera object using the destinationUp
vector such that:
Declaration
public bool MatchRigUpRigForward(Vector3 destinationUp, Vector3 destinationForward)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | destinationUp | The up vector that the rig's up vector will be matched to. |
Vector3 | destinationForward | The forward vector that will be matched to the forward vector of the rig object, which is the direction the player moves in Unity when walking forward in the physical world. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the rotation is performed. Otherwise, returns false. |
MoveCameraToWorldLocation(Vector3)
This function moves the camera to the world location provided by desiredWorldLocation. It does this by moving the rig object so that the camera's world location matches the desiredWorldLocation
Declaration
public bool MoveCameraToWorldLocation(Vector3 desiredWorldLocation)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | desiredWorldLocation | the position in world space that the camera should be moved to |
Returns
Type | Description |
---|---|
Boolean | Returns true if the move is performed. Otherwise, returns false. |
OnDestroy()
See
Declaration
protected void OnDestroy()
OnDrawGizmos()
Called when gizmos are drawn.
Declaration
protected virtual void OnDrawGizmos()
OnValidate()
See
Declaration
protected void OnValidate()
RotateAroundCameraPosition(Vector3, Single)
Rotates the rig object around the camera object's position in world space using the provided vector
as the rotation axis. The rig object is rotated by the amount of degrees provided in angleDegrees
.
Declaration
public bool RotateAroundCameraPosition(Vector3 vector, float angleDegrees)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The axis of the rotation. |
Single | angleDegrees | The amount of rotation in degrees. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the rotation is performed. Otherwise, returns false. |
RotateAroundCameraUsingRigUp(Single)
Rotates the rig object around the camera object by the provided angleDegrees
.
This rotation only occurs around the rig's Up vector
Declaration
public bool RotateAroundCameraUsingRigUp(float angleDegrees)
Parameters
Type | Name | Description |
---|---|---|
Single | angleDegrees | The amount of rotation in degrees. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the rotation is performed. Otherwise, returns false. |
Start()
See
Declaration
protected void Start()