/// <summary> /// Initialize this device. /// </summary> public virtual void InitDevice(VRContext context) { // Replace the center eye if needed. if (isCenterEye) { Transform t = transform; Transform trackingSpace = context.GetAnchor(VRNode.TrackingSpace, null); Transform centerEye = context.GetAnchor(VRNode.CenterEye, null); if (trackingSpace != null) { t.SetParent(trackingSpace); t.localPosition = Vector3.zero; t.localRotation = Quaternion.identity; t.localScale = Vector3.one; } if (centerEye != null) { // TODO : You may have a lot of work to do. foreach (Transform c in centerEye) { c.SetParent(t, false); } centerEye.gameObject.SetActive(false); // Log.d("VRDevice", "Replace origin center eye."); } context.SetAnchor(VRNode.CenterEye, t, true); } // m_MethodIsPresent = ReflectUtil.ParseDelegate <System.Func <bool> >(methodIsPresent); m_MethodRefreshRate = ReflectUtil.ParseDelegate <System.Func <float> >(methodRefreshRate); if (m_MethodRefreshRate == null) { float f; if (float.TryParse(methodRefreshRate, out f)) { m_MethodRefreshRate = () => (f); } } if (useUnityVR) // TODO : more method? { Log.i("VRDevice", "UnityVR loads a device(model = \"" + UnityEngine.VR.VRDevice.model + "\")."); switch (UnityEngine.VR.VRDevice.model) { case "Oculus Rift DK2": m_MethodRefreshRate = () => (75.0f); break; case "": //dummy, nothing is plugged in or no vr device m_MethodRefreshRate = () => (60.0f); break; #if !UNITY_EDITOR && UNITY_ANDROID default: // Cardboard,Gear VR and Daydream. m_MethodRefreshRate = () => (60.0f); break; #endif } } }
/// <summary> /// Center tracking to the current position and orientation of the HMD. /// </summary> public virtual void Recenter() { if (!m_MethodRecenterCached) { m_MethodRecenterCached = true; // if (m_MethodRecenter == null) { m_MethodRecenter = ReflectUtil.ParseDelegate <System.Action>(methodRecenter); } } if (m_MethodRecenter != null) { m_MethodRecenter(); } }