示例#1
0
 protected static void HandleScreenCaptureGameWitObjName()
 {
     if (m_IsShooted)
     {
         if (File.Exists(m_FullPath) == false)
         {
             if (EditorUtility.DisplayCancelableProgressBar("Generate screenshot", "file://" + m_FullPath, 0.5f))
             {
                 EditorUtility.ClearProgressBar();
                 m_IsShooted = false;
                 m_FullPath  = string.Empty;
                 GameObject.DestroyImmediate(m_ScreenCaptureObj);
             }
             EditorSceneManager.SaveOpenScenes();
         }
         else
         {
             EditorUtility.DisplayProgressBar("Generate screenshot", "file://" + m_FullPath, 1f);
             EditorUtility.ClearProgressBar();
             m_IsShooted = false;
             m_FullPath  = string.Empty;
             GameObject.DestroyImmediate(m_ScreenCaptureObj);
         }
     }
 }
    /// <summary>
    /// 执行变体搜集
    /// </summary>
    private async Task doShaderVariantsCollectAsync()
    {
        Debug.Log("doShaderVariantsCollect()");
        ShaderVariantOuputFolderPath = Application.dataPath + ShaderVariantsAssetPath;
        var outputassetsindex  = ShaderVariantOuputFolderPath.IndexOf("Assets");
        var outputrelativepath = ShaderVariantOuputFolderPath.Substring(outputassetsindex, ShaderVariantOuputFolderPath.Length - outputassetsindex);
        var svcoutputfilepath  = outputrelativepath + ShaderVariantsAssetFileName;

        Debug.Log(string.Format("Shader变体文件输出目录:{0}", ShaderVariantOuputFolderPath));
        Debug.Log(string.Format("Shader变体文件输出相对路径:{0}", svcoutputfilepath));
        if (!Directory.Exists(ShaderVariantOuputFolderPath))
        {
            Debug.Log(string.Format("Shader变体文件输出目录:{0}不存在,重新创建一个!", ShaderVariantOuputFolderPath));
            Directory.CreateDirectory(ShaderVariantOuputFolderPath);
        }
        EditorSceneManager.SaveOpenScenes();
        MethodInfo savecurrentsvc = typeof(ShaderUtil).GetMethod("SaveCurrentShaderVariantCollection", BindingFlags.NonPublic | BindingFlags.Static);

        savecurrentsvc.Invoke(null, new object[] { svcoutputfilepath });
        // 直接设置AB名字和Shader打包到一起
        var svcassetimporter = AssetImporter.GetAtPath(svcoutputfilepath);

        if (svcassetimporter != null)
        {
            svcassetimporter.assetBundleName = "shaderlist";
            DIYLog.Log(string.Format("设置资源:{0}的AB名字为:shaderlist", svcoutputfilepath));
            AssetDatabase.SaveAssets();
        }
        GameObject.DestroyImmediate(SVCCubeParentGo);
        EditorSceneManager.SaveOpenScenes();
        Debug.Log("保存完Shader变体文件!");
        await Task.Delay(1000);
    }
示例#3
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);
 }
    void OnGUI()
    {
        //Debug.Log(SceneManager.sceneCountInBuildSettings);
        int temp = 0;

        toggle = EditorGUILayout.Toggle("Save before loading", toggle);
        if (pain == null || pain.Count < SceneManager.sceneCountInBuildSettings || pain.Count > SceneManager.sceneCountInBuildSettings || safeCounter > 30)
        {
            PainInit(); safeCounter = 0;
        }

        for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
        {
            if (GUILayout.Button(suffering[i]))
            {
                if (toggle)
                {
                    EditorSceneManager.MarkAllScenesDirty();
                    EditorSceneManager.SaveOpenScenes();
                }

                EditorSceneManager.OpenScene(pain[temp]);
            }
            temp++;
        }

        safeCounter++;
    }
示例#5
0
    private void OpenMainAndCoreScene()
    {
        EditorSceneManager.SaveOpenScenes();

        var getScenePath = (projectInUploadFolder) ? "Assets/Upload/Scenes" : "Assets/Scenes";

        string levelFarmPath = "";
        string levelCorePath = "";

        foreach (var item in AssetDatabase.FindAssets("t:Scene", new string[1] {
            getScenePath
        }))
        {
            var path = AssetDatabase.GUIDToAssetPath(item);

            if (Path.GetFileNameWithoutExtension(path) == "Level_Farm")
            {
                levelFarmPath = path;
            }
            if (Path.GetFileNameWithoutExtension(path) == "Core")
            {
                levelCorePath = path;
            }
        }


        if (string.IsNullOrEmpty(levelCorePath) || string.IsNullOrEmpty(levelFarmPath))
        {
            Debug.LogError("Could not find scene: Core or Level_Farm");
            return;
        }

        EditorSceneManager.OpenScene(levelFarmPath);
        EditorSceneManager.OpenScene(levelCorePath, OpenSceneMode.Additive);
    }
示例#6
0
    //public static void BuildIOS()
    //{
    //    PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, bundleID);//测试用
    //    Debug.Log("CURRENT BUNDLE " + PlayerSettings.applicationIdentifier);
    //    BuildPlayer();
    //}
    static void BuildPlayer()
    {
        Debug.Log("Build is start" + System.DateTime.Now);
        string[] scenes = new string[] { scene };

#if !RELEASE
        EditorSceneManager.OpenScene(scene, OpenSceneMode.Single);
        GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/TapEnjoy/ZPlugins/GMPlugin/GMPlugin.prefab")).SetActive(true);
        EditorSceneManager.SaveOpenScenes();
        AssetDatabase.SaveAssets();
#endif

#if UNITY_ANDROID
        AndroidSettings();
        string to = "../android/game.apk";
        QuickAcessUtils.CheckDirectory(Path.GetDirectoryName(to));
        BuildPipeline.BuildPlayer(scenes, to, BuildTarget.Android, BuildOptions.None);
#elif UNITY_IOS
        string to = "../ios";
        to = Path.GetFullPath(to);
        QuickAcessUtils.CheckDirectory(to);
        BuildPipeline.BuildPlayer(scenes, to, BuildTarget.iOS, BuildOptions.None);
#else
        string to = "../win/game.exe";
        QuickAcessUtils.CheckDirectory(Path.GetDirectoryName(to));
        BuildPipeline.BuildPlayer(scenes, to, BuildTarget.StandaloneWindows, BuildOptions.None);
#endif
    }
示例#7
0
 private void SaveScenes()
 {
     if (_saveScenes && !EditorApplication.isPlaying)
     {
         EditorSceneManager.SaveOpenScenes();
     }
 }
    // Use this for initialization
    void Start()
    {
        // g = GameObject.Find("GameObject");

        //Component[] comp = GameObject.Find("Directional Light").GetComponents<Component>();

        //foreach(Component c in comp)
        //{
        //    if(c.GetType()==typeof(Transform))
        //    {
        //        continue;
        //    }

        //    CopyComponent(c, g);
        //}

        TaskInScene();

        for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
        {
            if (EditorSceneManager.GetActiveScene().buildIndex == i)
            {
                continue;
            }

            print(i);

            EditorSceneManager.OpenScene(SceneUtility.GetScenePathByBuildIndex(i), OpenSceneMode.Additive);
        }

        //EditorSceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(1));
        //DestroyImmediate(GetComponent<AutoUpdate>());
        EditorSceneManager.SaveOpenScenes();
    }
示例#9
0
    public static void performAllPreBuildTasks()
    {
        ClearLog();
        Debug.Log("Running all Pre-Build Tasks");
        //Setup
        EditorSceneManager.SaveOpenScenes();
        loadAllLevelScenes(false);
        loadAllLevelScenes(true);
        while (!allLevelScenesLoaded())
        {
            new WaitForSecondsRealtime(0.1f);
        }

        //Checklist
        bool keepScenesOpen = false;

        refreshSceneSavableObjectLists();
        //(new List<Func<bool>>()).ForEach(func => keepScenesOpen = keepScenesOpen || func);
        keepScenesOpen = ensureSavableObjectsHaveObjectInfo() || keepScenesOpen;
        keepScenesOpen = ensureMemoryObjectsHaveObjectInfo() || keepScenesOpen;
        keepScenesOpen = ensureUniqueObjectIDs() || keepScenesOpen;
        keepScenesOpen = ensureHiddenAreasAreProperlySetup() || keepScenesOpen;

        populateObjectManagerKnownObjectsList();

        //Cleanup
        EditorSceneManager.SaveOpenScenes();
        if (!keepScenesOpen)
        {
            loadAllLevelScenes(false);
        }
        //Finish
        Debug.Log("Finished all Pre-Build Tasks");
    }
示例#10
0
    public static void Initializate()
    {
        var Initializators = new List <IInitialization>();

        GameObject[]    objects = Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[];
        IInitialization outInitilizator;

        IInitialization[] bufInitilizators;

        for (int i = objects.Length - 1; i >= 0; i--)
        {
            if (objects[i].TryGetComponent <IInitialization>(out outInitilizator))
            {
                bufInitilizators = objects[i].GetComponents <IInitialization>();

                for (int k = 0; k < bufInitilizators.Length; k++)
                {
                    Initializators.Add(bufInitilizators[k]);
                }
            }
        }

        for (int i = 0; i < Initializators.Count; i++)
        {
            if (Initializators[i].AutoInitializate)
            {
                Debug.Log($"Инициализация {Initializators[i].GetType()}");
                Initializators[i].Initializate();
            }
        }

        EditorSceneManager.SaveOpenScenes();
    }
    private static void ResaveAllScenes()
    {
        EditorUtility.DisplayProgressBar(progressTitle, "Finding all scenes", 0);

        var scenes = AssetDatabase.FindAssets("t:SceneAsset");

        for (int i = 0; i < scenes.Length; ++i)
        {
            float  progress  = (float)i / scenes.Length;
            string scenePath = AssetDatabase.GUIDToAssetPath(scenes[i]);

            if (EditorUtility.DisplayCancelableProgressBar(progressTitle, "Opening scene: " + scenePath, progress))
            {
                break;
            }
            EditorSceneManager.OpenScene(scenePath);

            if (EditorUtility.DisplayCancelableProgressBar(progressTitle, "Saving scene: " + scenePath, progress))
            {
                break;
            }
            EditorSceneManager.SaveOpenScenes();
        }

        EditorUtility.ClearProgressBar();
    }
示例#12
0
 static void OnPlaymodeStateChanged()
 {
     if (EditorApplication.isPlaying == false)
     {
         EditorSceneManager.SaveOpenScenes();
     }
 }
        private static void SaveAllFSMsInBuild()
        {
            // Allow the user to save his work!
#if UNITY_PRE_5_3
            if (!EditorApplication.SaveCurrentSceneIfUserWantsTo())
#else
            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
#endif
            {
                return;
            }

            LoadPrefabsWithPlayMakerFSMComponents();

            foreach (var scene in EditorBuildSettings.scenes)
            {
                Debug.Log("Open Scene: " + scene.path);
#if UNITY_PRE_5_3
                EditorApplication.OpenScene(scene.path);
#else
                EditorSceneManager.OpenScene(scene.path);
#endif
                SaveAllLoadedFSMs();

#if UNITY_PRE_5_3
                if (!EditorApplication.SaveScene())
#else
                if (!EditorSceneManager.SaveOpenScenes())
#endif
                {
                    Debug.LogError("Could not save scene!");
                }
            }
        }
示例#14
0
        private void Save()
        {
            HashSet <GameObject> prefabs = new HashSet <GameObject>();

            foreach (var pair in mod)
            {
                pair.Key.textKey = pair.Value;
                EditorUtil.SetDirty(pair.Key);
                GameObject p = PrefabUtility.FindPrefabRoot(pair.Key.gameObject);
                if (p != null)
                {
                    prefabs.Add(p);
                }
            }
            mod.Clear();
            if (!prefabs.IsEmpty())
            {
                foreach (GameObject p in prefabs)
                {
                    PrefabUtility.ReplacePrefab(p, PrefabUtility.GetCorrespondingObjectFromSource(p), ReplacePrefabOptions.ConnectToPrefab);
                }
                AssetDatabase.SaveAssets();
                EditorSceneManager.SaveOpenScenes();
            }
        }
示例#15
0
 void Init()
 {
     EditorSceneManager.SaveOpenScenes();
     currentScene = EditorSceneManager.GetSceneManagerSetup();
     EditorSceneManager.OpenScene("Assets/PuzzleEditor/PuzzleEditorScene.unity");
     parent = GameObject.Find("Puzzle Creator Parent").transform;
 }
示例#16
0
        private static void Save()
        {
            EditorSceneManager.SaveOpenScenes();
            AssetDatabase.SaveAssets();

            ResetSaveDate();
        }
    public static void VimOpen()
    {
        Debug.Log("VimOpen");
        if (PlayerPrefs.HasKey("vim_unite") == false)
        {
            PlayerPrefs.SetString("vim_unite", "");
        }

        List <string> list = VimModeInfoWindow.GetSaveFileHistory();

        foreach (var val in Selection.assetGUIDs)
        {
            var path = AssetDatabase.GUIDToAssetPath(val);
            if (path.Contains(".cs"))
            {
                path = path.Replace("/", "\\");
                System.Diagnostics.Process.Start("MonoDevelop.exe", path);
                //			System.Diagnostics.Process.Start("C:\\yamashita\\github\\GVIM\\vim73\\win32\\gvim.exe", "--remote-tab-silent " + path);
                VimModeInfoWindow.AddSaveFileHistory(path);
            }
            else if (path.Contains(".unity"))
            {
                EditorSceneManager.SaveOpenScenes();
                EditorSceneManager.OpenScene(path, OpenSceneMode.Single);
                VimModeInfoWindow.AddSaveFileHistory(path);
            }

            Debug.Log(path);
//			Process.Start("MonoDevelop.exe", "C:\\yamashita\\github\\hakusura\\Assets\\Editor\\VimModeInfoWindow.cs");
        }
    }
示例#18
0
    public void Update()
    {
        // update times
        InPlayMode  = EditorApplication.isPlaying;
        CurrentTime = GetCurrentTime();


        if (CurrentTime >= NextSave)
        {
            if (InPlayMode && !SaveInPlayMode)
            {
                return;
            }

            // save scene
            EditorSceneManager.SaveOpenScenes();
            // save assets
            AssetDatabase.SaveAssets();

            LastSave = GetCurrentTime();
            NextSave = CurrentTime.AddMinutes(AutoSaveInterval);
        }

        this.Repaint();
    }
    // Static constructor that gets called when unity fires up.
    static AutoSaveEditor()
    {
        if (enableSave)
        {
            EditorApplication.playModeStateChanged += (PlayModeStateChange state) =>
            {
                if (enableSaveAfterPlay)
                {
                    // If we're about to run the scene...
                    if (!EditorApplication.isPlayingOrWillChangePlaymode || EditorApplication.isPlaying)
                    {
                        return;
                    }

                    // Save the scene and the assets.
                    Debug.Log("Auto Saving... ");
                    EditorSceneManager.SaveOpenScenes();
                    AssetDatabase.SaveAssets();
                }
            };

            if (enableSaveAfterTime)
            {
                // Also, every five minutes.
                nextSaveTime              = DateTime.Now.AddMinutes(mins);
                EditorApplication.update += Update;
            }
        }
    }
示例#20
0
    static void CopySelectionToAllScenes()
    {
        // First, save the open Scene
        EditorSceneManager.SaveOpenScenes();
        // Save the path of the currently opened scene, so we can re-open it later
        string currentScenePath = EditorSceneManager.GetActiveScene().path;
        // Save the name of the currently selected gameobject, so we can find this prefab in other scenes
        string currentSelection = Selection.activeGameObject.name;

        // For every scene in the build list
        foreach (UnityEditor.EditorBuildSettingsScene S in UnityEditor.EditorBuildSettings.scenes)
        {
            if (S.enabled)
            {
                // Open the scene in the editor
                EditorSceneManager.OpenScene(S.path);
                // Try to find the prefab in this scene by name
                GameObject Prefab = GameObject.Find(currentSelection);
                // If the prefab was found
                if (Prefab != null)
                {
                    // "Revert" the prefab instance to the newly updated prefab instance.
                    PrefabUtility.RevertPrefabInstance(Prefab);
                }
            }
        }
        // Return to the original scene that we were working in
        EditorSceneManager.OpenScene(currentScenePath);
    }
示例#21
0
    static EditorAutoSave()
    {
        EditorApplication.update += () =>
        {
            if (autoSaveEnabled)
            {
                if (!EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    if (lastAutoSave + TimeSpan.FromMinutes(5) < DateTime.UtcNow)
                    {
                        if (!messageLogged)
                        {
                            messageLogged = true;
                            Debug.Log("Editor auto save enabled");
                        }
                        lastAutoSave = DateTime.UtcNow + TimeSpan.FromMinutes(5);
                        EditorSceneManager.SaveOpenScenes();
                        AssetDatabase.SaveAssets();
                    }
                }
            }
        };

        EditorApplication.playModeStateChanged += PlayModeStateChange =>
        {
            lastAutoSave = DateTime.UtcNow + TimeSpan.FromMinutes(5);
        };
    }
示例#22
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);
 }
示例#23
0
    private void OpenStartMenu()
    {
        EditorSceneManager.SaveOpenScenes();

        var getScenePath = (projectInUploadFolder) ? "Assets/Upload/Scenes" : "Assets/Scenes";

        string levelStartMenu = "";

        foreach (var item in AssetDatabase.FindAssets("t:Scene", new string[1] {
            getScenePath
        }))
        {
            var path = AssetDatabase.GUIDToAssetPath(item);

            if (Path.GetFileNameWithoutExtension(path) == "StartMenu")
            {
                levelStartMenu = path;
            }
        }


        if (string.IsNullOrEmpty(levelStartMenu))
        {
            Debug.LogError("Could not find scene: StartMenu");
            return;
        }

        EditorSceneManager.OpenScene(levelStartMenu);
    }
    public static void WindowsBuildAndRun()
    {
        // Save any changes made to the Scene before Building
        EditorSceneManager.MarkAllScenesDirty();
        EditorSceneManager.SaveOpenScenes();

        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();

        buildPlayerOptions.scenes           = FindActiveScenesInBuildSettings();
        buildPlayerOptions.locationPathName = @"Build\Windows\" + Application.productName + ".exe";
        buildPlayerOptions.target           = BuildTarget.StandaloneWindows64;

        BuildReport  report  = BuildPipeline.BuildPlayer(buildPlayerOptions);
        BuildSummary summary = report.summary;

        if (summary.result == BuildResult.Succeeded)
        {
            UnityEngine.Debug.Log("Build succeeded!");
            // *** Option to launch Playmode in the Unity Editor after a successful build
            //EditorApplication.ExecuteMenuItem("Edit/Play");

            Process.Start(@"Build\Windows\" + Application.productName + ".exe");
            // *** FOR MULTIPLAYER TESTING *** Uncomment these lines if you need to test a multiplayer game
            //RunMultipleInstances();
        }

        if (summary.result == BuildResult.Failed)
        {
            UnityEngine.Debug.Log("*** WINDOWS BUILD FAILED! ***");
        }
    }
示例#25
0
        private static void SetLevelLoaderSceneName(string scenePath, string extraScenePath)
        {
            var sceneName = Path.GetFileNameWithoutExtension(extraScenePath);
            var modified  = ModifyRootGameObject <AdditiveLevelLoader>(scenePath, (levelLoader) =>
            {
                if (!string.Equals(levelLoader.sceneName, sceneName))
                {
                    levelLoader.sceneName = sceneName;
                    Debug.Log("BUILD:: Set scene name on additive level loader (" + levelLoader.ToString() + ") == " + levelLoader.sceneName);
                }
            });

            if (!modified)
            {
                var go = new GameObject("AdditiveLevelLoader");
                Undo.RegisterCreatedObjectUndo(go, "Created additive level loader");

                var levelLoader = Undo.AddComponent <AdditiveLevelLoader>(go);

                Undo.RecordObject(levelLoader, "Set additive level loader scene name");
                levelLoader.sceneName = sceneName;

                Undo.FlushUndoRecordObjects();
                EditorSceneManager.SaveOpenScenes();
                Debug.Log("BUILD:: Create an additive level loader & set scene name on it (" + levelLoader.ToString() + ") == " + levelLoader.sceneName);
            }
        }
示例#26
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        Activity activity = (Activity)target;

        if (GUILayout.Button("Open Activity"))
        {
            EditorSceneManager.SaveOpenScenes();

            if (!EditorSceneManager.GetSceneByName(R.S.MainScene).isLoaded)
            {
                EditorSceneManager.OpenScene("Assets/Scenes/Main.unity", OpenSceneMode.Additive);
            }

            for (int i = 0; i < EditorSceneManager.loadedSceneCount; i++)
            {
                Scene currentScene = EditorSceneManager.GetSceneAt(i);
                if (currentScene.name != R.S.MainScene)
                {
                    EditorSceneManager.CloseScene(EditorSceneManager.GetSceneAt(i), true);
                    i--;
                }
            }

            foreach (var i in activity.Scenes)
            {
                EditorSceneManager.OpenScene("Assets/Scenes/" + i + ".unity", OpenSceneMode.Additive);
            }

            EditorSceneManager.OpenScene("Assets/Scenes/LoadingScreen.unity", OpenSceneMode.Additive);
        }
    }
示例#27
0
    void AutosaveBlock()
    {
        if (GUILayout.Button("Save Scene", GUILayout.MaxHeight(20)))
        {
            EditorSceneManager.SaveOpenScenes();
        }



        autosaveToggle = EditorGUILayout.BeginToggleGroup("Autosave", autosaveToggle);

        EditorGUILayout.LabelField("Autosave Frequency : " + ((int)(1f / (autosaveDelay / 3600f))).ToString() + " save every hour");

        autosaveDelay = EditorGUILayout.Slider(autosaveDelay, 30f, 60 * 30);

        float nSave = (float)EditorApplication.timeSinceStartup - timer;

        EditorGUILayout.LabelField("Next save in " + (int)(10f * nSave) / 10f + " seconds");

        /*
         * if (autosaveDelay + timer < (float)EditorApplication.timeSinceStartup) {
         *
         * timer = (float)EditorApplication.timeSinceStartup;
         *
         * EditorSceneManager.SaveOpenScenes ();
         * }
         */


        EditorGUILayout.EndToggleGroup();
    }
示例#28
0
        private void ExecuteSpecial()
        {
            switch (systemKind)
            {
            case SystemKind.DoNothing:
                break;

            case SystemKind.SaveScene:
                if (EditorSceneManager.SaveOpenScenes())
                {
                    Debug.Log("Scene saved [" + DateTime.Now.ToString("HH:mm:ss") + "]");
                }
                break;

            case SystemKind.SaveBackup:
                if (SceneManager.sceneCount <= 0)
                {
                    return;
                }

                for (var i = 0; i < SceneManager.sceneCount; i++)
                {
                    var scene   = SceneManager.GetSceneAt(i);
                    var bkpName = scene.path.Replace(".unity", " " + DateTime.Now.ToString("MM-dd HH-mm-ss") + ".unity");
                    EditorSceneManager.SaveScene(scene, bkpName, true);
                    Debug.Log("Backup [" + bkpName + "]");
                }

                break;
            }
        }
示例#29
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);
        }
示例#30
0
        public static void ClearAndReStage()
        {
            // Clear Console
            var assembly = Assembly.GetAssembly(typeof(ActiveEditorTracker));
            var type     = assembly.GetType("UnityEditorInternal.LogEntries");

            if (type == null)
            {
                type = assembly.GetType("UnityEditor.LogEntries");
            }
            var method = type.GetMethod("Clear");

            method.Invoke(new object(), null);

            long time = System.DateTime.Now.Ticks;

            if (time - PrevDoTheThingTime < 5000000)
            {
                // Deselect
                Selection.activeObject = null;
                // Save
                if (!EditorApplication.isPlaying)
                {
                    EditorSceneManager.SaveOpenScenes();
                }
            }
            PrevDoTheThingTime = time;
        }