private void Start()
        {
            if (SceneButtonPrefab == null)
            {
                return;
            }

            SceneLauncherBuildIndex = SceneManager.GetActiveScene().buildIndex;

            // Determine the size of the buttons. Instantiate one of them so that we can check its bounds.
            SceneLauncherButton sceneButtonForSize = Instantiate(SceneButtonPrefab);
            var sceneButtonForSizeCollider         = sceneButtonForSize.GetComponent <Collider>();

            if (sceneButtonForSizeCollider != null)
            {
                sceneButtonSize = sceneButtonForSizeCollider.bounds.size;
            }

            for (int sceneIndex = 0; sceneIndex < sceneMapping.Length; ++sceneIndex)
            {
                if (sceneMapping[sceneIndex].IsButtonEnabled)
                {
                    CreateSceneButton(ButtonSpawnLocation, sceneIndex);
                }
            }

            Destroy(sceneButtonForSize.gameObject);
        }
示例#2
0
        private void Start()
        {
            if (SceneButtonPrefab == null)
            {
                return;
            }

            if (ReturnToSceneLauncherPrefab != null)
            {
                GameObject exsistReturnToSceneLauncher = GameObject.Find("ReturnToSceneLauncher(Clone)");
                if (exsistReturnToSceneLauncher == null)
                {
                    returnToSceneLauncher = Instantiate(ReturnToSceneLauncherPrefab);
                    DontDestroyOnLoad(returnToSceneLauncher);
                }

                if (returnToSceneLauncher.KeywordsAndResponses.Length > 0)
                {
                    // Set the response action of the first keyword to reload this scene.
                    int         sceneLauncherBuildIndex = SceneManager.GetActiveScene().buildIndex;
                    UnityAction keywordAction           = delegate
                    {
                        Debug.LogFormat("SceneLauncher: Returning to SceneLauncher scene {0}.", sceneLauncherBuildIndex);
                        SceneManager.LoadScene(sceneLauncherBuildIndex, LoadSceneMode.Single);
                        //Application.LoadLevelAdditive("SceneLauncher");
                        GameObject.Destroy(returnToSceneLauncher.gameObject);
                    };
                    returnToSceneLauncher.KeywordsAndResponses[0].Response.AddListener(keywordAction);
                }
            }

            // Determine the size of the buttons. Instantiate one of them so that we can check its bounds.
            SceneLauncherButton sceneButtonForSize         = Instantiate(SceneButtonPrefab);
            Collider            sceneButtonForSizeCollider = sceneButtonForSize.GetComponent <Collider>();

            if (sceneButtonForSizeCollider != null)
            {
                sceneButtonSize = sceneButtonForSizeCollider.bounds.size;
            }
            Destroy(sceneButtonForSize.gameObject);

            // Create an empty game object to serve as a parent for all the buttons we're about to create.
            GameObject buttonParent = new GameObject("Buttons");

            List <string> sceneNames = SceneList.Instance.GetSceneNames();

            for (int sceneIndex = 0; sceneIndex < sceneNames.Count; ++sceneIndex)
            {
                CreateSceneButton(buttonParent, sceneIndex, sceneNames);
            }
        }
示例#3
0
        private void Start()
        {
            if (SceneButtonPrefab == null)
            {
                return;
            }

            SceneLauncherBuildIndex = SceneManager.GetActiveScene().buildIndex;

            // Determine the size of the buttons. Instantiate one of them so that we can check its bounds.
            SceneLauncherButton sceneButtonForSize = Instantiate(SceneButtonPrefab);
            var sceneButtonForSizeCollider         = sceneButtonForSize.GetComponent <Collider>();

            if (sceneButtonForSizeCollider != null)
            {
                sceneButtonSize = sceneButtonForSizeCollider.bounds.size;
            }

            for (int sceneIndex = 0; sceneIndex < sceneMapping.Length; ++sceneIndex)
            {
                //UnityEngine.Debug.Log("sceneIndex: " + sceneIndex + " " + sceneMapping[sceneIndex].ScenePath + " is enabled: " + sceneMapping[sceneIndex].IsButtonEnabled);

                // Check scene name and enable
                if (sceneMapping[sceneIndex].ScenePath == "Assets/scenes/cube middle plane.unity")
                {
                    sceneMapping[sceneIndex].IsButtonEnabled = true;
                }
                else if (sceneMapping[sceneIndex].ScenePath == "Assets/scenes/pointing middle plane.unity")
                {
                    sceneMapping[sceneIndex].IsButtonEnabled = true;
                }

                if (sceneMapping[sceneIndex].IsButtonEnabled)
                {
                    CreateSceneButton(ButtonSpawnLocation, sceneIndex);
                }
            }

            Destroy(sceneButtonForSize.gameObject);
        }