Пример #1
0
 public static void BakeMultipleScenes(string[] paths)
 {
     if (paths.Length == 0)
     {
         return;
     }
     for (int i = 0; i < paths.Length; i++)
     {
         for (int j = i + 1; j < paths.Length; j++)
         {
             if (paths[i] == paths[j])
             {
                 throw new Exception("no duplication of scenes is allowed");
             }
         }
     }
     if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         return;
     }
     SceneSetup[] sceneManagerSetup = EditorSceneManager.GetSceneManagerSetup();
     EditorSceneManager.OpenScene(paths[0]);
     for (int k = 1; k < paths.Length; k++)
     {
         EditorSceneManager.OpenScene(paths[k], OpenSceneMode.Additive);
     }
     Lightmapping.Bake();
     EditorSceneManager.SaveOpenScenes();
     EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetup);
 }
        public static void LoadDataPackageInToEditor(LevelSceneData sceneData)
        {
            //Get the selected data
            if (sceneData)
            {
                int loadcount = sceneData.SceneList.Count;
                if (!String.IsNullOrEmpty(sceneData.MasterScene))
                {
                    loadcount++;
                }
                SceneSetup[] setup = new SceneSetup[loadcount];
                int          i     = 0;
                if (loadcount > sceneData.SceneList.Count)
                {
                    setup[0]          = new SceneSetup();
                    setup[0].path     = sceneData.MasterScene;
                    setup[0].isLoaded = true;
                    setup[0].isActive = true;

                    i = 1;
                }
                foreach (SceneData sdata in sceneData.SceneList)
                {
                    setup[i]          = new SceneSetup();
                    setup[i].path     = sdata.Path;
                    setup[i].isLoaded = true;
                    i++;
                }
                EditorSceneManager.RestoreSceneManagerSetup(setup);
            }
        }
Пример #3
0
    public void LoadSetupInclusive()
    {
        SceneSetup[] current  = EditorSceneManager.GetSceneManagerSetup();
        SceneSetup[] newSetup = new SceneSetup[current.Length + setup.Length];

        int newSetupIndex = 0;

        for (int i = 0; i < current.Length; i++)
        {
            newSetup[newSetupIndex] = current[i];
            newSetupIndex++;
        }
        for (int i = 0; i < setup.Length; i++)
        {
            newSetup[newSetupIndex] = new SceneSetup()
            {
                path     = setup[i].path,
                isLoaded = setup[i].isLoaded,
                isActive = false
            };
            newSetupIndex++;
        }

        EditorSceneManager.RestoreSceneManagerSetup(newSetup);
    }
Пример #4
0
        /// <summary>
        /// 生成烘焙数据
        /// </summary>
        public static void BakeGroupAsset(MapGroupAsset groupAsset)
        {
            //TODO:设置实时光照配置
            //保护现场
            SceneSetup[] sceneSetup = EditorSceneManager.GetSceneManagerSetup();

            //Setting
            for (int i = 0; i < 3; i++)
            {
                Scene s = EditorSceneManager.OpenScene(GetScenePath(groupAsset, i), OpenSceneMode.Single);
                {
                    Lightmapping.bakedGI    = false;
                    Lightmapping.realtimeGI = true;
                    LightmapEditorSettings.realtimeResolution = 4;
                }
                EditorSceneManager.SaveScene(s);
            }

            //恢复现场
            EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);

            //Bake
            string[] paths = { GetScenePath(groupAsset, 0), GetScenePath(groupAsset, 1), GetScenePath(groupAsset, 2) };
            Lightmapping.BakeMultipleScenes(paths); //这个API是异步的!

            groupAsset.baked = true;
        }
Пример #5
0
        static bool ValidateWrapper(Action action)
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                var originalSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                try
                {
                    action();
                    return(true);
                }
                catch (Exception e)
                {
                    ModestTree.Log.ErrorException(e);
                    return(false);
                }
                finally
                {
                    EditorSceneManager.RestoreSceneManagerSetup(originalSceneSetup);
                }
            }
            else
            {
                UnityEngine.Debug.Log("Validation cancelled - All scenes must be saved first for validation to take place");
                return(false);
            }
        }
Пример #6
0
        void ExitSkinEditMode()
        {
            if (editMode)
            {
                editMode = false;

                ActiveEditorTracker.sharedTracker.isLocked = false;

                if (SceneManager.GetActiveScene().path.Length <= 0)
                {
                    if (this.oldSetup != null && this.oldSetup.Length > 0)
                    {
                        EditorSceneManager.RestoreSceneManagerSetup(this.oldSetup);
                        this.oldSetup = null;
                    }
                    else
                    {
                        EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
                    }
                }

                Selection.activeObject = oldSelection;
                Tools.hidden           = false;

#if (UNITY_2019_1_OR_NEWER)
                SceneView.duringSceneGui -= this.OnSceneGUI;
#else
                SceneView.onSceneGUIDelegate -= this.OnSceneGUI;
#endif
            }
        }
        /// <summary>
        /// Updates Loader scene parameters to run the deck on start.
        /// </summary>
        /// <param name="deck">Slide Deck to use.</param>
        private static void updateLoaderScene(SlideDeck deck)
        {
            var sceneSetup = EditorSceneManager.GetSceneManagerSetup();
            var scene      = EditorSceneManager.OpenScene(SceneUtils.LoaderScenePath, OpenSceneMode.Single);
            var loader     = GameObject.FindObjectOfType <Loader>() as Loader;

            if (loader == null)
            {
                Debug.LogError("Failed to update Loader scene. Can't find Loader script");
                return;
            }

            var so = new SerializedObject(loader);

            so.Update();

            // Set properties.
            var prop = so.FindProperty("Properties");

            prop.objectReferenceValue = Properties.Instance;
            var d = so.FindProperty("Deck");

            d.objectReferenceValue = deck;

            so.ApplyModifiedProperties();

            EditorSceneManager.SaveScene(scene);
            EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);
        }
Пример #8
0
        // Returns true if succeeds without errors
        public static bool SaveThenRunPreserveSceneSetup(Action action)
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                var originalSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                try
                {
                    action();
                    return(true);
                }
                catch (Exception e)
                {
                    ModestTree.Log.ErrorException(e);
                    return(false);
                }
                finally
                {
                    EditorSceneManager.RestoreSceneManagerSetup(originalSceneSetup);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        static bool ValidateInternal()
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                var originalSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                try
                {
                    ZenUnityEditorUtil.ValidateCurrentSceneSetup();
                    Log.Info("All scenes validated successfully");
                    return(true);
                }
                catch (Exception e)
                {
                    Log.ErrorException(e);
                    return(false);
                }
                finally
                {
                    EditorSceneManager.RestoreSceneManagerSetup(originalSceneSetup);
                }
            }
            else
            {
                Debug.Log("Validation cancelled - All scenes must be saved first for validation to take place");
                return(false);
            }
        }
Пример #10
0
        public static bool ProcessScene(string sceneName, string processName, bool saveScenes, Action <UnityEngine.SceneManagement.Scene> customProcess)
        {
            bool Completed = true;

            SceneSetup[] sceneSetups = EditorSceneManager.GetSceneManagerSetup();
            if (saveScenes)
            {
                if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                {
                    return(false);
                }
            }
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            try
            {
                Scene scene = EditorSceneManager.OpenScene(EditorBuildSettings.scenes.First(x => x.path.Contains(sceneName)).path, OpenSceneMode.Single);
                customProcess(scene);
                if (saveScenes)
                {
                    EditorSceneManager.MarkSceneDirty(scene);
                    EditorSceneManager.SaveOpenScenes();
                    EditorSceneManager.CloseScene(scene, true);
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
            EditorUtility.ClearProgressBar();
            EditorSceneManager.RestoreSceneManagerSetup(sceneSetups);
            return(Completed);
        }
        void ExitSkinEditMode()
        {
            if (editMode)
            {
                editMode = false;

                ActiveEditorTracker.sharedTracker.isLocked = false;

                if (SceneManager.GetActiveScene().path.Length <= 0)
                {
                    if (this.oldSetup != null && this.oldSetup.Length > 0)
                    {
                        EditorSceneManager.RestoreSceneManagerSetup(this.oldSetup);
                        this.oldSetup = null;
                    }
                    else
                    {
                        EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
                    }
                }

                Selection.activeObject        = oldSelection;
                SceneView.onSceneGUIDelegate -= this.OnSceneGUI;
            }
        }
Пример #12
0
 internal void SwitchToAssetMode()
 {
     foreach (SceneStateCache cache in this.m_SceneStates)
     {
         if (cache.view != null)
         {
             cache.view.m_SceneViewState.showFog            = cache.state.showFog;
             cache.view.m_SceneViewState.showFlares         = cache.state.showFlares;
             cache.view.m_SceneViewState.showMaterialUpdate = cache.state.showMaterialUpdate;
             cache.view.m_SceneViewState.showSkybox         = cache.state.showSkybox;
             cache.view.m_SceneViewState.showImageEffects   = cache.state.showImageEffects;
         }
     }
     this.m_EditMode = EditMode.Stopping;
     this.DestroyEditor();
     this.ChangeInspectorLock(this.m_InspectorLocked);
     if (!EditorApplication.isUpdating && !Unsupported.IsDestroyScriptableObject(this))
     {
         if (SceneManager.GetActiveScene().path.Length <= 0)
         {
             if ((this.sceneSetup != null) && (this.sceneSetup.Length > 0))
             {
                 EditorSceneManager.RestoreSceneManagerSetup(this.sceneSetup);
                 this.sceneSetup = null;
             }
             else
             {
                 EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
             }
         }
     }
     else if (Unsupported.IsDestroyScriptableObject(this))
     {
Пример #13
0
 /// <summary>
 ///   <para>Bakes an array of scenes.</para>
 /// </summary>
 /// <param name="paths">The path of the scenes that should be baked.</param>
 public static void BakeMultipleScenes(string[] paths)
 {
     if (paths.Length == 0)
     {
         return;
     }
     for (int index1 = 0; index1 < paths.Length; ++index1)
     {
         for (int index2 = index1 + 1; index2 < paths.Length; ++index2)
         {
             if (paths[index1] == paths[index2])
             {
                 throw new Exception("no duplication of scenes is allowed");
             }
         }
     }
     if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         return;
     }
     SceneSetup[] sceneManagerSetup = EditorSceneManager.GetSceneManagerSetup();
     EditorSceneManager.OpenScene(paths[0]);
     for (int index = 1; index < paths.Length; ++index)
     {
         EditorSceneManager.OpenScene(paths[index], OpenSceneMode.Additive);
     }
     Lightmapping.Bake();
     EditorSceneManager.SaveOpenScenes();
     EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetup);
 }
        public void RunFinished(ITestResult result)
        {
            if (previousSceneSetup != null && previousSceneSetup.Length > 0)
            {
                try
                {
                    EditorSceneManager.RestoreSceneManagerSetup(previousSceneSetup);
                }
                catch (ArgumentException e)
                {
                    Debug.LogWarning(e.Message);
                }
            }
            else
            {
                foreach (var obj in FindObjectsOfType <GameObject>())
                {
                    if (obj != null && obj.transform.parent != null && (obj.transform.parent.hideFlags & HideFlags.DontSaveInEditor) == HideFlags.DontSaveInEditor && obj.transform.parent.gameObject != null)
                    {
                        DestroyImmediate(obj.transform.parent.gameObject);
                    }
                }

                EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
            }
            CleanUp();
        }
Пример #15
0
 /// <summary>
 /// Restores saved editor scene setup.
 /// </summary>
 private void restoreEditorState()
 {
     if (defaultSceneSetup != null && defaultSceneSetup.Length > 0)
     {
         EditorSceneManager.RestoreSceneManagerSetup(defaultSceneSetup);
     }
 }
Пример #16
0
        public static void InstallUpdate()
        {
            Requirement requirements = MeetsUnityRequirements();

            if (!requirements.success)
            {
                EditorUtility.DisplayDialog(REQUIREMENTS_TITLE, requirements.message, "Ok");
                return;
            }

            Debug.Log("Preparing installation...");
            if (!File.Exists(Path.Combine(Application.dataPath, PACKAGE_PATH)))
            {
                string path = Path.Combine(Application.dataPath, PACKAGE_PATH);
                Debug.LogError("Unable to locate Package file at: " + path);
                return;
            }

            if (!File.Exists(Path.Combine(Application.dataPath, CONFIG_PATH)))
            {
                string path = Path.Combine(Application.dataPath, CONFIG_PATH);
                Debug.LogError("Unable to locate Config file at: " + path);
                return;
            }

            EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
            SceneSetup[] scenesSetup = EditorSceneManager.GetSceneManagerSetup();
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);

            string[] removeFolders = Config.GetUpdate().removeDirectories;
            for (int i = 0; i < removeFolders.Length; ++i)
            {
                string assetPath = Path.Combine(Application.dataPath, removeFolders[i]);
                if (File.Exists(assetPath) || Directory.Exists(assetPath))
                {
                    FileUtil.DeleteFileOrDirectory(assetPath);
                }
            }

            Debug.Log("Installing Game Creator...");
            AssetDatabase.ImportPackage(
                Path.Combine(ASSETS_PATH, PACKAGE_PATH),
                Config.GetUpdate().interactiveInstall
                );

            Debug.Log("<b>Installation Complete</b>!");
            if (scenesSetup != null && scenesSetup.Length > 0)
            {
                EditorSceneManager.RestoreSceneManagerSetup(scenesSetup);
            }

            EditorUtility.CopySerialized(Config.GetUpdate(), Config.GetCurrent());

            EditorUtility.DisplayDialog(
                MSG_COMPLETE1,
                string.Format(MSG_COMPLETE2, Config.GetUpdate().version),
                "Ok"
                );
        }
Пример #17
0
 public void TearDown()
 {
     EditorUtility.ClearProgressBar();
     if (sceneManagerSetup != null && sceneManagerSetup.Length > 0)
     {
         EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetup);
     }
 }
Пример #18
0
    public static void LoadVideoDay()
    {
        var SceneSetup = (MultiSceneSetup)AssetDatabase.LoadAssetAtPath("Assets/Demo/MSE/Loader.asset", typeof(MultiSceneSetup));

        EditorSceneManager.RestoreSceneManagerSetup(SceneSetup.Setups);

        Debug.Log(string.Format("Scene setup '{0}' restored", Path.GetFileNameWithoutExtension(AssetDatabase.LoadAssetAtPath("Assets/Demo/MSE/Loader.asset", typeof(MultiSceneSetup)).name)));
    }
Пример #19
0
 void LoadSceneSession(int id)
 {
     if (sessions[id] == null)
     {
         return;
     }
     EditorSceneManager.RestoreSceneManagerSetup(sessions[id].setup);
 }
Пример #20
0
 internal void SwitchToAssetMode()
 {
     using (List <AvatarEditor.SceneStateCache> .Enumerator enumerator = this.m_SceneStates.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             AvatarEditor.SceneStateCache current = enumerator.Current;
             if (!((UnityEngine.Object)current.view == (UnityEngine.Object)null))
             {
                 current.view.m_SceneViewState.showFog            = current.state.showFog;
                 current.view.m_SceneViewState.showFlares         = current.state.showFlares;
                 current.view.m_SceneViewState.showMaterialUpdate = current.state.showMaterialUpdate;
                 current.view.m_SceneViewState.showSkybox         = current.state.showSkybox;
             }
         }
     }
     this.m_EditMode = AvatarEditor.EditMode.Stopping;
     this.DestroyEditor();
     this.ChangeInspectorLock(this.m_InspectorLocked);
     if (!EditorApplication.isUpdating && !Unsupported.IsDestroyScriptableObject((ScriptableObject)this))
     {
         if (SceneManager.GetActiveScene().path.Length <= 0)
         {
             if (this.sceneSetup != null && this.sceneSetup.Length > 0)
             {
                 EditorSceneManager.RestoreSceneManagerSetup(this.sceneSetup);
                 this.sceneSetup = (SceneSetup[])null;
             }
             else
             {
                 EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
             }
         }
     }
     else if (Unsupported.IsDestroyScriptableObject((ScriptableObject)this))
     {
         // ISSUE: object of a compiler-generated type is created
         // ISSUE: variable of a compiler-generated type
         AvatarEditor.\u003CSwitchToAssetMode\u003Ec__AnonStorey9C modeCAnonStorey9C = new AvatarEditor.\u003CSwitchToAssetMode\u003Ec__AnonStorey9C();
         // ISSUE: reference to a compiler-generated field
         modeCAnonStorey9C.\u003C\u003Ef__this = this;
         // ISSUE: reference to a compiler-generated field
         modeCAnonStorey9C.CleanUpSceneOnDestroy = (EditorApplication.CallbackFunction)null;
         // ISSUE: reference to a compiler-generated field
         // ISSUE: reference to a compiler-generated method
         modeCAnonStorey9C.CleanUpSceneOnDestroy = new EditorApplication.CallbackFunction(modeCAnonStorey9C.\u003C\u003Em__1C9);
         // ISSUE: reference to a compiler-generated field
         EditorApplication.update += modeCAnonStorey9C.CleanUpSceneOnDestroy;
     }
     this.m_GameObject = (GameObject)null;
     this.m_ModelBones = (Dictionary <Transform, bool>)null;
     this.SelectAsset();
     if (this.m_CameFromImportSettings)
     {
         return;
     }
     this.m_EditMode = AvatarEditor.EditMode.NotEditing;
 }
Пример #21
0
        public static void BakeMultipleScenes(string[] paths)
        {
            if (paths.Length == 0)
            {
                return;
            }

            for (int i = 0; i < paths.Length; i++)
            {
                for (int j = i + 1; j < paths.Length; j++)
                {
                    if (paths[i] == paths[j])
                    {
                        throw new System.Exception("no duplication of scenes is allowed");
                    }
                }
            }

            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            var sceneSetup = EditorSceneManager.GetSceneManagerSetup();

            // Restore old scene setup once the bake finishes
            Action OnBakeFinish = null;

            OnBakeFinish = () =>
            {
                EditorSceneManager.SaveOpenScenes();
                if (sceneSetup.Length > 0)
                {
                    EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);
                }
                Lightmapping.bakeCompleted -= OnBakeFinish;
            };

            // Call BakeAsync when all scenes are loaded and attach cleanup delegate
            EditorSceneManager.SceneOpenedCallback BakeOnAllOpen = null;
            BakeOnAllOpen = (UnityEngine.SceneManagement.Scene scene, SceneManagement.OpenSceneMode loadSceneMode) =>
            {
                if (EditorSceneManager.loadedSceneCount == paths.Length)
                {
                    BakeAsync();
                    Lightmapping.bakeCompleted     += OnBakeFinish;
                    EditorSceneManager.sceneOpened -= BakeOnAllOpen;
                }
            };

            EditorSceneManager.sceneOpened += BakeOnAllOpen;

            EditorSceneManager.OpenScene(paths[0]);
            for (int i = 1; i < paths.Length; i++)
            {
                EditorSceneManager.OpenScene(paths[i], OpenSceneMode.Additive);
            }
        }
Пример #22
0
 static void LoadSceneMain()
 {
     EditorSceneManager.RestoreSceneManagerSetup(new SceneSetup[] {
         new SceneSetup()
         {
             path = scenePath + "Game.unity", isActive = true, isLoaded = true
         },
     });
 }
 static void LoadMaster()
 {
     SceneSetup[] sceneSetup = new SceneSetup[1];
     sceneSetup[0]          = new SceneSetup();
     sceneSetup[0].path     = GameMasterSettings.GAMEMASTER_SCENE;
     sceneSetup[0].isLoaded = true;
     sceneSetup[0].isActive = true;
     EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);
 }
Пример #24
0
    public static void LoadDemoNight()
    {
        var SceneSetup = (MultiSceneSetup)AssetDatabase.LoadAssetAtPath("Assets/Demo/MSE/Night.asset", typeof(MultiSceneSetup));

        EditorSceneManager.RestoreSceneManagerSetup(SceneSetup.Setups);

        Debug.Log(string.Format("Scene setup '{0}' restored", Path.GetFileNameWithoutExtension(AssetDatabase.LoadAssetAtPath("Assets/Demo/MSE/Night.asset", typeof(MultiSceneSetup)).name)));

        GameObject.FindObjectOfType <LevelLightmapData>().LoadLightingScenario(1);
    }
Пример #25
0
        static void Open(MultiScene multiScene)
        {
            bool cancelled = !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();

            if (cancelled)
            {
                return;
            }

            EditorSceneManager.RestoreSceneManagerSetup(multiScene.ToSceneSetups());
        }
 public void RestoreSceneManagerSetup()
 {
     if ((sceneManagerSetupBeforeTest == null) || (sceneManagerSetupBeforeTest.Length == 0))
     {
         EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
     }
     else
     {
         EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetupBeforeTest);
     }
 }
Пример #27
0
        public static void RestoreSceneSetup()
        {
            var assetPath = ConvertFullAbsolutePathToAssetPath(
                TryGetSelectedFilePathInProjectsTab());

            var loader = AssetDatabase.LoadAssetAtPath <MultiSceneSetup>(assetPath);

            EditorSceneManager.RestoreSceneManagerSetup(loader.Setups);

            Debug.Log(string.Format("Scene setup '{0}' restored", Path.GetFileNameWithoutExtension(assetPath)));
        }
Пример #28
0
        private static void RemoveFromAllScenes()
        {
            if (!OpenOkCancelDialog($"{ITEM_NAME_REMOVE_FROM_ALL_SCENES}しますか?"))
            {
                return;
            }

            var sceneSetups = EditorSceneManager.GetSceneManagerSetup();

            // FindAssets は Packages フォルダも対象になっているので
            // Assets フォルダ以下のシーンのみを抽出
            var scenePaths = AssetDatabase
                             .FindAssets("t:scene")
                             .Select(x => AssetDatabase.GUIDToAssetPath(x))
                             .Where(x => x.StartsWith("Assets/"))
                             .ToArray()
            ;

            var count = scenePaths.Length;

            try
            {
                for (var i = 0; i < count; i++)
                {
                    var num       = i + 1;
                    var progress  = ( float )num / count;
                    var scenePath = scenePaths[i];
                    var scene     = EditorSceneManager.OpenScene(scenePath);

                    EditorUtility.DisplayProgressBar
                    (
                        ITEM_NAME_REMOVE_FROM_ALL_SCENES,
                        $"{num}/{count} {scenePath}",
                        progress
                    );

                    RemoveFromScene(scene);
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();

                // Untitled なシーンは復元できず、SceneSetup[] の要素数が 0 になる
                // Untitled なシーンを復元しようとすると下記のエラーが発生するので if で確認
                // ArgumentException: Invalid SceneManagerSetup:
                if (0 < sceneSetups.Length)
                {
                    EditorSceneManager.RestoreSceneManagerSetup(sceneSetups);
                }
            }

            OpenOkDialog($"{ITEM_NAME_REMOVE_FROM_ALL_SCENES}しました");
        }
    static void LoadSceneSetup()
    {
        string path = EditorUtility.OpenFilePanel("Select SceneSetup ScriptableObject", "Assets/Editor", "asset");

        if (path.StartsWith(Application.dataPath))
        {
            path = string.Format("Assets{0}", path.Substring(Application.dataPath.Length));
        }

        SceneSetup[] sceneSetup = AssetDatabase.LoadAssetAtPath <SavedSceneSetup> (path).sceneSetup;
        EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);
    }
        public void Dispose()
        {
            if (m_SceneBackup)
            {
                if (!m_Scenes.IsNullOrEmpty())
                    EditorSceneManager.RestoreSceneManagerSetup(m_Scenes);
                else
                    EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
            }

            if (Directory.Exists(m_TempPath))
                Directory.Delete(m_TempPath, true);
        }