void Awake() { Time.fixedDeltaTime = Time.timeScale / XRDevice.refreshRate; rigidbody = GetComponent <Rigidbody>(); collider = GetComponent <CapsuleCollider>(); XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); }
void SetCameraHeight() { float cameraYOffset = m_StationaryCameraYOffset; if (m_TrackingSpace == TrackingSpace.Stationary) { XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary); // InputTracking.Recenter(); } else if (m_TrackingSpace == TrackingSpace.RoomScale) { if (XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale)) { cameraYOffset = 0; } } //Move camera to correct height if (m_CameraFloorOffsetObject) { var yOffset = m_StationaryCameraYOffset; if (m_InACar) { yOffset += m_CarHeightOffset; } m_CameraFloorOffsetObject.transform.localPosition = new Vector3(m_CameraFloorOffsetObject.transform.localPosition.x, yOffset, m_CameraFloorOffsetObject.transform.localPosition.z); } }
// Use this for initialization void Start() { rotationalSpeed = 10; tcounter = GameObject.FindGameObjectWithTag("counter").GetComponent <TextMesh>(); particles = GameObject.FindGameObjectWithTag("particles").GetComponent <ParticleSystem>(); a = GetComponent <Animator>(); button = GameObject.FindGameObjectWithTag("button"); if (XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale)) { // RoomScale mode was set successfully. App can now assume that y=0 in Unity world coordinate represents the floor. Debug.Log("Roomscale success"); } else { Debug.Log("Roomscale not"); // RoomScale mode was not set successfully. App cannot make assumptions about where the floor plane is. } ger = new GestureRecognizer(); //ger.SetRecognizableGestures(GestureSettings.Tap); //ger.SetRecognizableGestures(GestureSettings.Hold); ger.TappedEvent += GestureRecognizer_TappedEvent; ger.HoldCompletedEvent += GestureRecognizer_HoldEvent; ger.HoldStartedEvent += GestureRecognizer_HoldStarted; ger.StartCapturingGestures(); conv = GameObject.FindGameObjectWithTag("spawner"); }
/// <summary> /// Updates the <see cref="TrackingSpaceType"/> on the XR device. /// </summary> private void SetTrackingSpace() { TrackingSpaceType trackingSpace; // In current versions of Unity, there are two types of tracking spaces. For boundaries, if the scale // is not Room or Standing, it currently maps to TrackingSpaceType.Stationary. switch (Scale) { case ExperienceScale.Standing: case ExperienceScale.Room: trackingSpace = TrackingSpaceType.RoomScale; break; case ExperienceScale.OrientationOnly: case ExperienceScale.Seated: case ExperienceScale.World: trackingSpace = TrackingSpaceType.Stationary; break; default: trackingSpace = TrackingSpaceType.Stationary; Debug.LogWarning("Unknown / unsupported ExperienceScale. Defaulting to Stationary tracking space."); break; } bool trackingSpaceSet = XRDevice.SetTrackingSpaceType(trackingSpace); if (!trackingSpaceSet) { // TODO: how best to handle this scenario? } }
// Use this for initialization void Start() { _lastFramePosition = transform.position; XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); _currentGrabObject = null; _isGrabbing = false; }
private void Start() { LeftHandInputDevice = new PlayerHandInputDevice(HumanBodyPart.LeftHand, settings); RightHandInputDevice = new PlayerHandInputDevice(HumanBodyPart.RightHand, settings); SubsystemManager.GetInstances(_subsystems); foreach (var inputSubsystem in _subsystems) { Debug.Log("Detected subsystem " + inputSubsystem.GetType()); inputSubsystem.TrySetTrackingOriginMode(TrackingOriginModeFlags.Floor); } if (_subsystems.Count == 0) { XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); Debug.LogWarning("No Subsystems detected"); } impulse = new byte[20]; var caps = new HapticCapabilities(); int clipCount = (int)(caps.bufferFrequencyHz * 2); impulse = new byte[clipCount]; for (int i = 0; i < clipCount; i++) { impulse[i] = byte.MaxValue; } }
private void Awake() { // Destroy any duplicate instances that may have been created if (_instance != null && _instance != this) { Destroy(this); return; } _instance = this; #if UNITY_2019_3_OR_NEWER InputDevices.deviceConfigChanged += onDeviceChanged; InputDevices.deviceConnected += onDeviceChanged; InputDevices.deviceDisconnected += onDeviceChanged; #endif // Update all device properties List <InputDevice> devices = new List <InputDevice>(); InputDevices.GetDevices(devices); setDeviceProperties(); // Init Tracking Origin. Deprecated, but currently the only working solution. XRDevice.SetTrackingSpaceType(TrackingSpaceType); }
protected override void Awake() { base.Awake(); #if UNITY_WSA && UNITY_2017_2_OR_NEWER if (HolographicSettings.IsDisplayOpaque) { XRDevice.SetTrackingSpaceType(opaqueTrackingSpaceType); } else { // Removed for now, until the HoloLens tracking space type story is more clear. //XRDevice.SetTrackingSpaceType(transparentTrackingSpaceType); Destroy(this); return; } // Render the floor based on if you are in editor or immersive device. RenderFloorQuad(); // Render boundary if configured. SetBoundaryRendering(); // Create a volume out of the specified user boundary. CalculateBoundaryVolume(); #endif }
void SetCameraHeight() { float cameraYOffset = m_StationaryCameraYOffset; if (m_TrackingSpace == TrackingSpace.Stationary) { XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary); // make the user face to the forward direction InputTracking.Recenter(); } // if on a room-scale experience, we disregard the height the user entered else if (m_TrackingSpace == TrackingSpace.RoomScale) { if (XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale)) { cameraYOffset = 0; } } //Move floor offset to correct height if (m_CameraFloorOffsetObject) { m_CameraFloorOffsetObject.transform.localPosition = new Vector3(m_CameraFloorOffsetObject.transform.localPosition.x, cameraYOffset, m_CameraFloorOffsetObject.transform.localPosition.z); } }
/// <summary> /// Initialization. /// </summary> private IEnumerator Start() { XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); playerSpace = new GameObject("Play Space"); playerSpace.transform.parent = transform.parent; //playerSpace.transform.localPosition = InputTracking.GetLocalPosition (XRNode.TrackingReference); //playerSpace.transform.localRotation = InputTracking.GetLocalRotation (XRNode.TrackingReference); leftHand = new GameObject("Left Hand"); leftHand.transform.parent = transform.parent; rightHand = new GameObject("Right Hand"); rightHand.transform.parent = transform.parent; yield return(StartCoroutine(DoSetLanguage(keyboardLayout))); validationNotice.SetActive(false); infoNotice.SetActive(false); successNotice.SetActive(false); UpdateDisplayText(); PlaceholderVisibility(); initialized = true; }
void SetCameraHeight() { float cameraYOffset = _stationaryCameraYOffset; if (_trackingSpace == TrackingSpace.Stationary) { XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary); InputTracking.Recenter(); } else if (_trackingSpace == TrackingSpace.RoomScale) { if (XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale)) { cameraYOffset = 0; } } if (_cameraFloorOffsetObject) { _cameraFloorOffsetObject.transform.localPosition = new Vector3( _cameraFloorOffsetObject.transform.localPosition.x, cameraYOffset, _cameraFloorOffsetObject.transform.localPosition.z ); } }
void SetCameraHeight() { var cameraYOffset = this.m_StationaryCameraYOffset; if (this.m_TrackingSpace == TrackingSpace.Stationary) { XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary); InputTracking.Recenter(); } else if (this.m_TrackingSpace == TrackingSpace.RoomScale) { if (XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale)) { cameraYOffset = 0; } } //Move camera to correct height if (this.m_CameraFloorOffsetObject) { this.m_CameraFloorOffsetObject.transform.localPosition = new Vector3( this.m_CameraFloorOffsetObject.transform.localPosition.x, cameraYOffset, this.m_CameraFloorOffsetObject.transform.localPosition.z); } }
void Init() { var devices = new List <InputDevice>(); InputDevices.GetDevicesAtXRNode(XRNode.LeftHand, devices); if (devices.Count == 1) { ld = devices[0]; } devices = new List <InputDevice>(); InputDevices.GetDevicesAtXRNode(XRNode.RightHand, devices); if (devices.Count == 1) { rd = devices[0]; } XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); Vector3 p1, p2; ld.TryGetFeatureValue(CommonUsages.devicePosition, out p1); rd.TryGetFeatureValue(CommonUsages.devicePosition, out p2); if (p1 == Vector3.zero || p2 == Vector3.zero) { Invoke("Init", 1.0f); } }
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); }
/// <summary> /// Updates the <see href="https://docs.unity3d.com/ScriptReference/XR.TrackingSpaceType.html">TrackingSpaceType</see> on the XR device. /// </summary> protected override void SetTrackingSpace() { if (Application.isPlaying) { TrackingSpaceType trackingSpace; // In current versions of Unity, there are two types of tracking spaces. For boundaries, if the scale // is not Room or Standing, it currently maps to TrackingSpaceType.Stationary. switch (Scale) { case ExperienceScale.Standing: case ExperienceScale.Room: trackingSpace = TrackingSpaceType.RoomScale; break; case ExperienceScale.OrientationOnly: case ExperienceScale.Seated: case ExperienceScale.World: trackingSpace = TrackingSpaceType.Stationary; break; default: trackingSpace = TrackingSpaceType.Stationary; Debug.LogWarning("Unknown / unsupported ExperienceScale. Defaulting to Stationary tracking space."); break; } InputTracking.disablePositionalTracking = Scale == ExperienceScale.OrientationOnly; if (!XRDevice.SetTrackingSpaceType(trackingSpace)) { Debug.LogWarning($"MRTK was unable to set Tracking Space to {trackingSpace}"); } } }
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); }
private void SetTrackingSpaceType() { if (XRDevice.isPresent) { XRDevice.SetTrackingSpaceType(WebXRManager.Instance.TrackingSpace); Debug.Log("Tracking Space: " + XRDevice.GetTrackingSpaceType()); } }
//private bool _isGrabbing; void Start() { animator = GetComponent <Animator>(); _lastFramePosition = transform.position; XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); _currentGrabObject = null; //_isGrabbing = false; }
private void Start() { // InputTracking.Recenter() // This only works with seated and standing experiences. Room scale experiences are not effected by Recenter. var ok = XRDevice.SetTrackingSpaceType(UnityEngine.XR.TrackingSpaceType.Stationary); Debug.LogFormat("TrackingSpace : {0}, {1}", XRDevice.GetTrackingSpaceType(), ok); }
private void SetTrackingSpaceType() { if (XRDevice.isPresent) { XRDevice.SetTrackingSpaceType(TrackingSpace); Debug.Log("Tracking Space: " + XRDevice.GetTrackingSpaceType()); } }
private void Awake() { //XRSettings.enabled = false; //XRSettings.showDeviceView = true; XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary); mainCamera = GetComponentInChildren <Camera>(); InputTracking.Recenter(); }
void ResetViewAction() { // Valve.VR.OpenVR.System.ResetSeatedZeroPose (); // Valve.VR.OpenVR.Compositor.SetTrackingSpace (Valve.VR.ETrackingUniverseOrigin.TrackingUniverseSeated); // SteamVR.instance.hmd.ResetSeatedZeroPose (); // SteamVR.instance.hmd.ResetSeatedZeroPose XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary); }
// Start is called before the first frame update void Start() { Debug.Log("<color=orange>[MasterSlaveSystem]XRDevice.model = " + XRDevice.model + "</color>"); if (string.IsNullOrEmpty(XRDevice.model) || XRDevice.isPresent == false) { Debug.Log("<color=orange>[MasterSlaveSystem]HMDが見つからなかった、もしくはXR Settingsが無効です。IKノードを無効化します </color>"); enabled = false; } XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); }
private void SetTrackingSpaceType() { #if UNITY_EDITOR if (XRDevice.isPresent) { XRDevice.SetTrackingSpaceType(WebVRManager.Instance.TrackingSpace); Debug.Log("Tracking Space: " + XRDevice.GetTrackingSpaceType()); } #endif }
// Use this for initialization void Start() { if (XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale)) { Debug.Log("Roomscale tracking enabled"); } else { Debug.LogError("Roomscale tracking failed"); } }
void Awake() { #if ProjectCore Destroy(this.gameObject); #else Time.fixedDeltaTime = Time.timeScale / XRDevice.refreshRate; rigidbody = GetComponent <Rigidbody>(); collider = GetComponent <CapsuleCollider>(); XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); #endif }
// Use this for initialization void Start() { if (XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale)) { // RoomScale mode was set successfully. App can now assume that y=0 in Unity world coordinate represents the floor. } else { // RoomScale mode was not set successfully. App cannot make assumptions about where the floor plane is. Debug.Log("Failed to set roomscale mode"); } }
// *Hopefully gets the roation of the controllers and matches that to the roation of the item* // *private Transform _objectRotation;* // Use this for initialization void Start() { // Clearing all variables back to zero _currentObject = null; _lastFramePosition = transform.position; _isHeld = false; // Determining the tracking space available XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); }
public virtual void SetTrackingOriginMode(TrackingOriginModeFlags trackingOrigin) { #if UNITY_2019_4 // 2019.4 Needs to use XRDevice.SetTrackingSpaceType; TrySetTrackingOriginMode does not function properly. if (trackingOrigin == TrackingOriginModeFlags.Floor) { XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); } #endif // Any other versions (including 2019.4) may go ahead and use TrySetTrackingSpaceType StartCoroutine(changeOriginModeRoutine(trackingOrigin)); }
// Use this for initialization void Start() { _lastFramePosition = transform.position; XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); currentGrabObject = null; _isGrabbing = false; _grabCollider = GetComponent <SphereCollider>(); _grabCollider.radius = GrabDistance; }