Class TrackedPoseDriver
The TrackedPoseDriver component applies the current Pose value of a tracked device to the transform of the GameObject. TrackedPoseDriver can track multiple types of devices including XR HMDs, controllers, and remotes.
Inherited Members
Namespace: UnityEngine.SpatialTracking
Syntax
[DefaultExecutionOrder(-30000)]
[Serializable]
[AddComponentMenu("XR/Tracked Pose Driver")]
[HelpURL("https://docs.unity.cn/Packages/com.unity.xr.legacyinputhelpers@2.1/manual/index.html")]
public class TrackedPoseDriver : MonoBehaviour
Fields
m_OriginPose
The origin pose is the offset applied to any tracking data. This is only used when in legacy compatibility mode.
Declaration
protected Pose m_OriginPose
Field Value
Type | Description |
---|---|
Pose |
Properties
deviceType
This is used to indicate which pose the TrackedPoseDriver is currently tracking.
Declaration
public TrackedPoseDriver.DeviceType deviceType { get; }
Property Value
Type | Description |
---|---|
TrackedPoseDriver.DeviceType |
originPose
originPose is an offset applied to any tracking data read from this object. Setting this value should be reserved for dealing with edge-cases, such as achieving parity between room-scale (floor centered) and stationary (head centered) tracking - without having to alter the transform hierarchy. For user locomotion and gameplay purposes you are usually better off just moving the parent transform of this object.
Declaration
public Pose originPose { get; set; }
Property Value
Type | Description |
---|---|
Pose |
poseProviderComponent
Optional: This field holds the reference to the BasePoseProvider instance that, if set, will be used to override the behavior of the TrackedPoseDriver. When this field is empty, the TrackedPoseDriver will operate as per usual, with pose data being retrieved from the device or pose settings of the TrackedPoseDriver. When this field is set, the pose data will be provided by the attached BasePoseProvider. The device or pose fields will be hidden as they are no longer used to control the parent GameObject Transform.
Declaration
public BasePoseProvider poseProviderComponent { get; set; }
Property Value
Type | Description |
---|---|
BasePoseProvider |
poseSource
The pose being tracked by the tracked pose driver
Declaration
public TrackedPoseDriver.TrackedPose poseSource { get; }
Property Value
Type | Description |
---|---|
TrackedPoseDriver.TrackedPose |
trackingType
The tracking type being used by the tracked pose driver
Declaration
public TrackedPoseDriver.TrackingType trackingType { get; set; }
Property Value
Type | Description |
---|---|
TrackedPoseDriver.TrackingType |
updateType
The update type being used by the tracked pose driver
Declaration
public TrackedPoseDriver.UpdateType updateType { get; set; }
Property Value
Type | Description |
---|---|
TrackedPoseDriver.UpdateType |
UseRelativeTransform
This is used to indicate whether the TrackedPoseDriver will use the object's original transform as its basis.
Declaration
public bool UseRelativeTransform { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Awake()
Declaration
protected virtual void Awake()
FixedUpdate()
Declaration
protected virtual void FixedUpdate()
OnBeforeRender()
Declaration
[BeforeRenderOrder(-30000)]
protected virtual void OnBeforeRender()
OnDestroy()
Declaration
protected virtual void OnDestroy()
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
protected virtual void OnEnable()
PerformUpdate()
PerformUpdate queries the data from the selected pose source, and then calls SetLocalTransform(Vector3, Quaternion, PoseDataFlags) to apply the pose.
Declaration
protected virtual void PerformUpdate()
SetLocalTransform(Vector3, Quaternion, PoseDataFlags)
Sets the transform that is being driven by the TrackedPoseDriver. will only correct set the rotation or position depending on the PoseDataFlags
Declaration
protected virtual void SetLocalTransform(Vector3 newPosition, Quaternion newRotation, PoseDataFlags poseFlags)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | newPosition | The position to apply. |
Quaternion | newRotation | The rotation to apply. |
PoseDataFlags | poseFlags | The flags indiciating which of the position/rotation values are provided by the calling code. |
SetPoseSource(TrackedPoseDriver.DeviceType, TrackedPoseDriver.TrackedPose)
This method is used to set the device / pose pair for the SpatialTracking.TrackedPoseDriver. setting an invalid combination of these values will return false.
Declaration
public bool SetPoseSource(TrackedPoseDriver.DeviceType deviceType, TrackedPoseDriver.TrackedPose pose)
Parameters
Type | Name | Description |
---|---|---|
TrackedPoseDriver.DeviceType | deviceType | The device type that we wish to track |
TrackedPoseDriver.TrackedPose | pose | The pose source that we wish to track |
Returns
Type | Description |
---|---|
Boolean | true if the values provided are sensible, otherwise false |
TransformPoseByOriginIfNeeded(Pose)
This is only used when running in legacy mode, and will fake the behavior of the old implicit camera tracking. This will transform by the origin pose if necessary.
Declaration
protected Pose TransformPoseByOriginIfNeeded(Pose pose)
Parameters
Type | Name | Description |
---|---|---|
Pose | pose | Pose to transform by the origin if in relative transform mode. |
Returns
Type | Description |
---|---|
Pose | The pose, with the applied transform if in Relative Transform mode. |
Update()
Declaration
protected virtual void Update()