예제 #1
0
        // Necessary because a Unity scene's build index isn't the index according to GetSceneAt(int);
        private static SceneWrapper FindWrapperForUnityScene(UnityEngine.SceneManagement.Scene scene)
        {
            SceneWrapper result = SceneWrapper.NullScene;

            // Initialize our internal list of SceneWrappers if we haven't yet.
            if (SceneManagerEditor.IsEmpty())
            {
                SceneManagerEditor.Init();
            }

            // We need to go through the unity scenes to find the given one.
            for (int i = 0; i < SceneManagerEditor.SceneCount; ++i)
            {
                var unityScene = UnityEditor.SceneManagement.EditorSceneManager.GetSceneAt(i);

                if (unityScene == scene)
                {
                    var wrapper = _scenes[i];
                    var message = string.Format("Inconsistent path for unity scene {0} and SceneWrapper {1}",
                                                unityScene.path, wrapper.Scene.path);

                    Debug.AssertFormat(unityScene.path == wrapper.Scene.path, message);

                    result = wrapper;
                    break;
                }
            }

            return(result);
        }
예제 #2
0
        public static void Init()
        {
            _scenes = new SceneWrapper[SceneCount];

            for (int i = 0; i < _scenes.Length; ++i)
            {
                var unityScene = UnityEditor.SceneManagement.EditorSceneManager.GetSceneAt(i);

                _scenes[i] = new SceneWrapper(unityScene, i);
            }
        }