public static string[] AdditionalScenePaths(this SceneDefinition sceneDefinition)
 {
     string[] finalAdditionalScenes = new string[sceneDefinition.additionalScenes.Length];
     for (int i = 0; i < sceneDefinition.additionalScenes.Length; i++)
     {
         finalAdditionalScenes[i] = sceneDefinition.additionalScenes[i].SceneFilePath();
     }
     return(finalAdditionalScenes);
 }
        void OnEnable()
        {
            gameScenes.Clear();

            foreach (string sceneAssetPath in AssetDatabase.FindAssets("t:sceneDefinition").Select(s => AssetDatabase.GUIDToAssetPath(s)))
            {
                SceneDefinition sceneDefinition = AssetDatabase.LoadAssetAtPath <SceneDefinition>(sceneAssetPath);
                gameScenes.Add(new GameScenePath(sceneDefinition.PrimaryScene, sceneDefinition.PrimaryScenePath()));
            }

            gameScenes = gameScenes.OrderBy(x => x.sceneName).ToList();
        }
        public static string[] AllScenePaths(this SceneDefinition sceneDefinition)
        {
            string[] allScenes = new string[sceneDefinition.additionalScenes.Length + 2];

            allScenes[0] = SceneDefinition.entryScenePath;
            allScenes[1] = sceneDefinition.primaryScene.SceneFilePath();
            for (int i = 0; i < sceneDefinition.additionalScenes.Length; i++)
            {
                allScenes[2 + i] = sceneDefinition.additionalScenes[i].SceneFilePath();
            }
            return(allScenes);
        }
Exemple #4
0
        static UnityEngine.SceneManagement.Scene RootScene()
        {
            for (int i = 0; i < EditorSceneManager.loadedSceneCount; i++)
            {
                UnityEngine.SceneManagement.Scene scene = EditorSceneManager.GetSceneAt(i);
                SceneDefinition sceneDefintion          = SceneDefinition_Editor.FromPath(scene.path);
                if (sceneDefintion != null)
                {
                    return(scene);
                }
            }

            return(new UnityEngine.SceneManagement.Scene());
        }
Exemple #5
0
        static SceneDefinition FindSceneDefinition()
        {
            foreach (SceneSetup sceneSetup in EditorSceneManager.GetSceneManagerSetup())
            {
                if (!sceneSetup.isLoaded)
                {
                    continue;
                }

                SceneDefinition sceneDefintion = SceneDefinition_Editor.FromPath(sceneSetup.path);
                if (sceneDefintion != null)
                {
                    return(sceneDefintion);
                }
            }

            return(null);
        }
Exemple #6
0
        public static void RefreshCurrentSceneDefinition(bool refreshScenes = true)
        {
            if (ignoreSceneEvents || EditorApplication.isPlaying)
            {
                return;
            }

            currentDefinition = FindSceneDefinition();
            OnDefinitionChange();

            if (currentDefinition == null)
            {
                return;
            }

            if (refreshScenes)
            {
                RefreshLoadedScenes();
            }
        }
        public static SceneDefinition CreateFromScene(UnityEngine.SceneManagement.Scene scene)
        {
            SceneDefinition asset      = ScriptableObject.CreateInstance <SceneDefinition>();
            SceneAsset      sceneAsset = AssetDatabase.LoadAssetAtPath <SceneAsset>(scene.path);

            asset.primaryScene = new SceneField(sceneAsset, sceneAsset.name);

            string assetPath = AssetPathFromScenePath(scene.path);

            string projectDirectory = Path.GetDirectoryName(Application.dataPath);
            string directory        = Path.Combine(projectDirectory, Path.GetDirectoryName(assetPath));

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            AssetDatabase.CreateAsset(asset, assetPath);

            return(asset);
        }
 public static string PrimaryScenePath(this SceneDefinition sceneDefinition)
 {
     return(sceneDefinition.primaryScene.SceneFilePath());
 }
Exemple #9
0
 public SceneLoadInfo(SceneDefinition sceneDefinition)
 {
     this.sceneDefinition = new Saves.SavedObjectReference <SceneDefinition>(sceneDefinition);
 }