Ejemplo n.º 1
0
        /// <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
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 public static void SetAnchor(VRNode node, Transform value)
 {
     if (main == null)
     {
         return;
     }
     main.SetAnchor(node, value, true);
 }