Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            Debug.Log("OnSceneLoaded: " + scene.name);

            if (pairingUI == null && GameObject.FindObjectsOfType <VRT_PairingUI>().Length > 0)
            {
                pairingUI = GameObject.FindObjectsOfType <VRT_PairingUI>()[0];
            }

            if (pairingUI != null && !pairingSuccessfull)
            {
                StartCoroutine(Pair());
            }
        }
Ejemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
            if (VRTracker.Manager.VRT_Manager.Instance.spectator)
            {
                gameObject.SetActive(false);
                if (gameScene != null)
                {
                    if (SceneManager.GetActiveScene().name != gameScene.SceneName.Split('/')[gameScene.SceneName.Split('/').Length - 1])
                    {
                        SceneManager.LoadScene(gameScene);
                    }
                }
                else if (SceneManager.GetActiveScene().name != gameScene.SceneName.Split('/')[gameScene.SceneName.Split('/').Length - 1])
                {
                    Debug.LogWarning("Could not load Game Scene in Spectator mode as the Game Scene is not linked in VRT_PairingManager");
                }
                return;
            }
            else
            {
                DontDestroyOnLoad(this);
            }

            SceneManager.sceneLoaded += OnSceneLoaded;
            VRTracker.Manager.VRT_Manager.Instance.OnAvailableTag += AddAvailableTag;

            if (pairingUI == null)
            {
                pairingUI = GetComponent <VRT_PairingUI>();
            }
            if (pairingUI == null)
            {
                pairingUI = GetComponent <VRT_PairingUIStandardAssets>();
            }


            // If we couldn't find the Pairing UI on Start, it means we did not started from the Pairing scene, but the Main Scene
            // So we need to save the information
            if (pairingUI == null)
            {
                if (gameScene == null)
                {
                    gameScene = new SceneField(SceneManager.GetActiveScene());
                }

                StartCoroutine(PairFromMainScene());
            }

            // Started from the pairing scene
            else
            {
                pairingScene = new SceneField(SceneManager.GetActiveScene());
                Debug.Log("Type Of Pairing Scene " + pairingScene.GetType().ToString());
                if (VRTracker.Manager.VRT_Manager.Instance.spectator)
                {
                    if (gameScene.SceneName != "")
                    {
                        SceneManager.LoadScene(gameScene);
                    }
                    else // Load next scene in Build setting if no Game Scene was set manually in the Pairing Manager
                    {
                        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
                    }
                }
                // Not spectator
                else
                {
                    StartCoroutine(Pair());
                }
            }
        }