Exemplo n.º 1
0
        public static void Initialize(bool forceUnityVRToOpenVR = false)
        {
            if (_instance == null && initializing == false)
            {
                initializing = true;
                GameObject steamVRObject = null;

                if (forceUnityVRToOpenVR)
                {
                    forcingInitialization = true;
                }

                SteamVR_Render renderInstance = GameObject.FindObjectOfType <SteamVR_Render>();
                if (renderInstance != null)
                {
                    steamVRObject = renderInstance.gameObject;
                }

                SteamVR_Behaviour behaviourInstance = GameObject.FindObjectOfType <SteamVR_Behaviour>();
                if (behaviourInstance != null)
                {
                    steamVRObject = behaviourInstance.gameObject;
                }

                if (steamVRObject == null)
                {
                    GameObject objectInstance = new GameObject("[SteamVR]");
                    _instance = objectInstance.AddComponent <SteamVR_Behaviour>();
                    _instance.steamvr_render = objectInstance.AddComponent <SteamVR_Render>();
                }
                else
                {
                    behaviourInstance = steamVRObject.GetComponent <SteamVR_Behaviour>();
                    if (behaviourInstance == null)
                    {
                        behaviourInstance = steamVRObject.AddComponent <SteamVR_Behaviour>();
                    }

                    if (renderInstance != null)
                    {
                        behaviourInstance.steamvr_render = renderInstance;
                    }
                    else
                    {
                        behaviourInstance.steamvr_render = steamVRObject.GetComponent <SteamVR_Render>();
                        if (behaviourInstance.steamvr_render == null)
                        {
                            behaviourInstance.steamvr_render = steamVRObject.AddComponent <SteamVR_Render>();
                        }
                    }

                    _instance = behaviourInstance;
                }

                /*if (_instance != null && _instance.doNotDestroy)
                 *  GameObject.DontDestroyOnLoad(_instance.transform.root.gameObject);*/

                initializing = false;
            }
        }
Exemplo n.º 2
0
        public static void Initialize(bool forceUnityVRToOpenVR = false)
        {
            if (!((UnityEngine.Object)SteamVR_Behaviour._instance == (UnityEngine.Object)null) || SteamVR_Behaviour.initializing)
            {
                return;
            }
            SteamVR_Behaviour.initializing = true;
            GameObject gameObject1 = (GameObject)null;

            if (forceUnityVRToOpenVR)
            {
                SteamVR_Behaviour.forcingInitialization = true;
            }
            SteamVR_Render objectOfType1 = UnityEngine.Object.FindObjectOfType <SteamVR_Render>();

            if ((UnityEngine.Object)objectOfType1 != (UnityEngine.Object)null)
            {
                gameObject1 = objectOfType1.gameObject;
            }
            SteamVR_Behaviour objectOfType2 = UnityEngine.Object.FindObjectOfType <SteamVR_Behaviour>();

            if ((UnityEngine.Object)objectOfType2 != (UnityEngine.Object)null)
            {
                gameObject1 = objectOfType2.gameObject;
            }
            if ((UnityEngine.Object)gameObject1 == (UnityEngine.Object)null)
            {
                GameObject gameObject2 = new GameObject("[SteamVR]");
                SteamVR_Behaviour._instance = gameObject2.AddComponent <SteamVR_Behaviour>();
                SteamVR_Behaviour._instance.steamvr_render = gameObject2.AddComponent <SteamVR_Render>();
                gameObject2.AddComponent <MelonCoroutineCallbacks>();
            }
            else
            {
                SteamVR_Behaviour steamVrBehaviour = gameObject1.GetComponent <SteamVR_Behaviour>();
                if ((UnityEngine.Object)steamVrBehaviour == (UnityEngine.Object)null)
                {
                    steamVrBehaviour = gameObject1.AddComponent <SteamVR_Behaviour>();
                }
                if ((UnityEngine.Object)objectOfType1 != (UnityEngine.Object)null)
                {
                    steamVrBehaviour.steamvr_render = objectOfType1;
                }
                else
                {
                    steamVrBehaviour.steamvr_render = gameObject1.GetComponent <SteamVR_Render>();
                    if ((UnityEngine.Object)steamVrBehaviour.steamvr_render == (UnityEngine.Object)null)
                    {
                        steamVrBehaviour.steamvr_render = gameObject1.AddComponent <SteamVR_Render>();
                    }
                }
                SteamVR_Behaviour._instance = steamVrBehaviour;
            }
            if ((UnityEngine.Object)SteamVR_Behaviour._instance != (UnityEngine.Object)null && SteamVR_Behaviour._instance.doNotDestroy)
            {
                UnityEngine.Object.DontDestroyOnLoad((UnityEngine.Object)SteamVR_Behaviour._instance.transform.root.gameObject);
            }
            SteamVR_Behaviour.initializing = false;
        }
Exemplo n.º 3
0
        private IEnumerator DoInitializeSteamVR(bool forceUnityVRToOpenVR = false)
        {
            SteamVR_Behaviour steamVrBehaviour = this;

            XRDevice.deviceLoaded += new System.Action <string>(steamVrBehaviour.XRDevice_deviceLoaded);
            XRSettings.LoadDeviceByName("OpenVR");
            while (!steamVrBehaviour.loadedOpenVRDeviceSuccess)
            {
                yield return((object)null);
            }
            XRDevice.deviceLoaded -= new System.Action <string>(steamVrBehaviour.XRDevice_deviceLoaded);
            steamVrBehaviour.EnableOpenVR();
        }
Exemplo n.º 4
0
        public static void Initialize()
        {
            if (_instance == null && initializing == false)
            {
                initializing = true;
                GameObject steamVRObject = null;

                SteamVR_Render renderInstance = GameObject.FindObjectOfType <SteamVR_Render>();
                if (renderInstance != null)
                {
                    steamVRObject = renderInstance.gameObject;
                }

                SteamVR_Behaviour behaviourInstance = GameObject.FindObjectOfType <SteamVR_Behaviour>();
                if (behaviourInstance != null)
                {
                    steamVRObject = behaviourInstance.gameObject;
                }

                if (steamVRObject == null)
                {
                    GameObject objectInstance = new GameObject("[SteamVR]");
                    _instance = objectInstance.AddComponent <SteamVR_Behaviour>();
                    _instance.steamvr_render = objectInstance.AddComponent <SteamVR_Render>();
                }
                else
                {
                    behaviourInstance = steamVRObject.GetComponent <SteamVR_Behaviour>();
                    if (behaviourInstance == null)
                    {
                        behaviourInstance = steamVRObject.AddComponent <SteamVR_Behaviour>();
                    }

                    if (renderInstance != null)
                    {
                        behaviourInstance.steamvr_render = renderInstance;
                    }
                    else
                    {
                        behaviourInstance.steamvr_render = steamVRObject.GetComponent <SteamVR_Render>();
                        if (behaviourInstance.steamvr_render == null)
                        {
                            behaviourInstance.steamvr_render = steamVRObject.AddComponent <SteamVR_Render>();
                        }
                    }

                    _instance = behaviourInstance;
                }
                initializing = false;
            }
        }
Exemplo n.º 5
0
 public static void Initialize(bool forceUnityVRMode = false)
 {
     if (forceUnityVRMode)
     {
         SteamVR_Behaviour.instance.InitializeSteamVR(true);
         return;
     }
     if (SteamVR._instance == null)
     {
         SteamVR._instance = SteamVR.CreateInstance();
         if (SteamVR._instance == null)
         {
             SteamVR._enabled = false;
         }
     }
     if (SteamVR._enabled)
     {
         SteamVR_Behaviour.Initialize(forceUnityVRMode);
     }
 }