Exemple #1
0
        static void InitControllers()
        {
            if (!controllersReady)
            {
#if UNITY_5_6
                /* hack hack hack for SteamVR < 1.2.2 on Unity 5.6 */
                if (typeof(SteamVR_UpdatePoses).GetMethod("OnPreCull",
                                                          System.Reflection.BindingFlags.Instance |
                                                          System.Reflection.BindingFlags.Public |
                                                          System.Reflection.BindingFlags.NonPublic) != null)
                {
                    if (GetHeadTransform().GetComponent <SteamVR_UpdatePoses>() == null)
                    {
                        GetHeadTransform().gameObject.AddComponent <SteamVR_UpdatePoses>();
                    }
                }
#endif
                Controller._InitControllers(GetBaroqueVRManager());

                Transform left_tr, right_tr;
                if (!GetBaroqueVRManager().GetControllerTransforms(out left_tr, out right_tr))
                {
                    controllers = new Controller[0];
                    return;
                }
                controllers      = new Controller[2];
                left_controller  = InitController(left_tr, 0);
                right_controller = InitController(right_tr, 1);
                controllersReady = true;

                if (!globallyReady)
                {
                    GetBaroqueVRManager().InitializeControllers();

                    SceneManager.sceneUnloaded += (scene) => { controllersReady = false; };
                    globallyReady = true;
                }
            }
            else
            {
                /* this occurs during scene unloading, when the controller objects have already
                 * been destroyed.  Make an empty list in this case. */
                controllers = new Controller[0];
            }
        }
Exemple #2
0
        static void InitControllers()
        {
            if (!controllersReady)
            {
#if UNITY_5_6
                /* hack hack hack for SteamVR < 1.2.2 on Unity 5.6 */
                if (typeof(SteamVR_UpdatePoses).GetMethod("OnPreCull",
                                                          System.Reflection.BindingFlags.Instance |
                                                          System.Reflection.BindingFlags.Public |
                                                          System.Reflection.BindingFlags.NonPublic) != null)
                {
                    if (GetHeadTransform().GetComponent <SteamVR_UpdatePoses>() == null)
                    {
                        GetHeadTransform().gameObject.AddComponent <SteamVR_UpdatePoses>();
                    }
                }
#endif
                Controller._InitControllers();
                controllers      = new Controller[2];
                left_controller  = InitController(GetSteamVRManager_Left().gameObject, 0);
                right_controller = InitController(GetSteamVRManager_Right().gameObject, 1);
                controllersReady = true;

                if (!globallyReady)
                {
                    SteamVR_Events.NewPosesApplied.AddListener(OnNewPosesApplied);
                    SceneManager.sceneUnloaded += (scene) => { controllersReady = false; };
                    globallyReady = true;
                }
            }
            else
            {
                /* this occurs during scene unloading, when the controller objects have already
                 * been destroyed.  Make an empty list in this case. */
                controllers = new Controller[0];
            }
        }