public bool SetTrackingSpaceType(TrackingSpaceType newSpaceType) { TrackingSpaceType current = XRDevice.GetTrackingSpaceType(); if (current != newSpaceType) { bool newValue = XRDevice.SetTrackingSpaceType(newSpaceType); Debug.Assert(newValue != false, "Failed to set tracking space type"); current = XRDevice.GetTrackingSpaceType(); Debug.Assert(current == newSpaceType, "Unexpected space type after set"); if (origin != null) { if (current == TrackingSpaceType.Stationary) { origin.transform.localPosition = new Vector3(0f, .5f, 0f); } else { origin.transform.localPosition = Vector3.zero; } } StartCoroutine(TraceCameraPosition(3f)); return(newValue); } else { TraceHelper.Log("Ignoring Tracking spaceType " + newSpaceType); } return(true); }
/// Utility helper to migrate from TrackingSpace to TrackingOrigin seamlessly void UpgradeTrackingSpaceToTrackingOriginMode() { #if UNITY_2019_3_OR_NEWER // Disable Obsolete warnings for TrackingSpaceType, explicitly to allow a proper upgrade path. #pragma warning disable 0618 if (m_TrackingOriginMode == TrackingOriginModeFlags.Unknown && m_TrackingSpace <= TrackingSpaceType.RoomScale) { switch (m_TrackingSpace) { case TrackingSpaceType.RoomScale: { m_TrackingOriginMode = TrackingOriginModeFlags.Floor; break; } case TrackingSpaceType.Stationary: { m_TrackingOriginMode = TrackingOriginModeFlags.Device; break; } default: break; } // Tag is Invalid not to be used. m_TrackingSpace = (TrackingSpaceType)3; #if UNITY_EDITOR EditorUtility.SetDirty(this); #endif //UNITY_EDITOR #pragma warning restore 0618 } #endif //UNITY_2019_3_OR_NEWER }
public override void OnActivated() { m_prevTrackingSpace = VRDevice.GetTrackingSpaceType(); UpdateTrackingSpaceType(); EnsureDeviceStateLength(3); }
public bool SetTrackingSpaceType(TrackingSpaceType newSpaceType) { TrackingSpaceType currentSpaceType = XRDevice.GetTrackingSpaceType(); bool result = true; if (currentSpaceType != newSpaceType) { result = XRDevice.SetTrackingSpaceType(newSpaceType); Debug.Assert(result != false, "Failed to set tracking space type"); currentSpaceType = XRDevice.GetTrackingSpaceType(); Debug.Assert(currentSpaceType == newSpaceType, "Unexpected space type after set"); if (origin != null) { if (currentSpaceType == TrackingSpaceType.Stationary) { origin.transform.localPosition = new Vector3(0f, .5f, 0f); } else { origin.transform.localPosition = Vector3.zero; } } } Debug.Log("Space type is now: " + currentSpaceType.ToString()); return(result); }
public override void OnActivated() { m_prevTrackingSpace = XRDevice.GetTrackingSpaceType(); UpdateTrackingSpaceType(); EnsureDeviceStateLength(16); m_index2nodeID = new ulong[GetDeviceStateLength()]; m_index2nodeValidity = new bool[GetDeviceStateLength()]; m_index2nodeTouched = new bool[GetDeviceStateLength()]; }
public override void OnActivated() { #pragma warning disable CS0618 m_prevTrackingSpace = XRDevice.GetTrackingSpaceType(); #pragma warning restore CS0618 UpdateTrackingSpaceType(); EnsureDeviceStateLength(16); m_index2nodeID = new ulong[GetDeviceStateLength()]; m_index2nodeValidity = new bool[GetDeviceStateLength()]; m_index2nodeTouched = new bool[GetDeviceStateLength()]; }
// Disable Obsolete warnings for TrackingSpaceType, explicitely to allow for using legacy data if available. #pragma warning disable 0618 void SetupCameraLegacy(TrackingSpaceType trackingSpace) { float cameraYOffset = m_CameraYOffset; XRDevice.SetTrackingSpaceType(trackingSpace); if (trackingSpace == TrackingSpaceType.Stationary) { InputTracking.Recenter(); } else if (trackingSpace == TrackingSpaceType.RoomScale) { cameraYOffset = 0; } // Move camera to correct height if (m_CameraFloorOffsetObject) { m_CameraFloorOffsetObject.transform.localPosition = new Vector3(m_CameraFloorOffsetObject.transform.localPosition.x, cameraYOffset, m_CameraFloorOffsetObject.transform.localPosition.z); } }
public override void OnActivated() { m_prevTrackingSpace = XRDevice.GetTrackingSpaceType(); UpdateTrackingSpaceType(); EnsureDeviceStateLength(16); m_index2nodeID = new ulong[GetDeviceStateLength()]; m_index2nodeValidity = new bool[GetDeviceStateLength()]; m_index2nodeTouched = new bool[GetDeviceStateLength()]; if (s_nodeType2DeviceClass == null) { s_nodeType2DeviceClass = new EnumArray <XRNode, VRModuleDeviceClass>(VRModuleDeviceClass.Invalid); s_nodeType2DeviceClass[XRNode.Head] = VRModuleDeviceClass.HMD; s_nodeType2DeviceClass[XRNode.RightHand] = VRModuleDeviceClass.Controller; s_nodeType2DeviceClass[XRNode.LeftHand] = VRModuleDeviceClass.Controller; s_nodeType2DeviceClass[XRNode.GameController] = VRModuleDeviceClass.Controller; s_nodeType2DeviceClass[XRNode.HardwareTracker] = VRModuleDeviceClass.GenericTracker; s_nodeType2DeviceClass[XRNode.TrackingReference] = VRModuleDeviceClass.TrackingReference; } }
bool SetupCamera() { if (m_RequestedTrackingMode == UserRequestedTrackingMode.Floor) { SetupCameraLegacy(TrackingSpaceType.RoomScale); } else if (m_RequestedTrackingMode == UserRequestedTrackingMode.Device) { SetupCameraLegacy(TrackingSpaceType.Stationary); } else if (m_RequestedTrackingMode == UserRequestedTrackingMode.Default) { TrackingSpaceType tst = XRDevice.GetTrackingSpaceType(); SetupCameraLegacy(tst); } else { Debug.LogWarning("CameraOffset.SetupCamera: Unknown requested "); } return(true); }
void Start() { trackingSpaceType = TrackingSpaceType.Stationary; XRDevice.SetTrackingSpaceType(trackingSpaceType); }
public static extern bool SetTrackingSpaceType(TrackingSpaceType trackingSpaceType);
public static bool SetTrackingSpaceType(TrackingSpaceType trackingSpaceType) { throw new NotSupportedException("VRDevice has been moved and renamed. Use UnityEngine.XR.XRDevice instead."); }
public override void OnActivated() { m_prevTrackingSpace = VRDevice.GetTrackingSpaceType(); UpdateTrackingSpaceType(); }
private void SaveTrackingSpaceType() { m_prevTrackingSpace = VRDevice.GetTrackingSpaceType(); }