EditorApplication.SaveScene 保存场景


static function SaveScene (path : string) : bool

Description描述

Save the scene at path.

保存场景到指定路径。

All paths are relative to the project folder. Like: "Assets/MyScenes/MyScene.unity"

所有的路径都是相对于工程文件夹,例如"Assets/MyScenes/MyScene.unity"

EditorApplication.SaveScene 保存场景

Simple Editor Window that saves each 300 seconds the current scene.
简单的编辑器窗口,每300秒保存当前场景。

// Simple editor window that autosaves  the working scene  //简单的编辑器窗口,可以自动保存工作场景// Make sure to have this window opened to be able to execute the auto save. //确保这个窗口开着, 这样才能执行自动保存import UnityEditor;class SimpleAutoSave extends EditorWindow {var saveTime : float = 300;var nextSave : float = 0;@MenuItem("Example/Simple autoSave")static function Init() {var window : SimpleAutoSave =EditorWindow.GetWindowWithRect(SimpleAutoSave,Rect(0,0,165,40));window.Show();}function OnGUI() {EditorGUILayout.LabelField("Save Each:", saveTime + " Secs");var timeToSave : int = nextSave - EditorApplication.timeSinceStartup;EditorGUILayout.LabelField("Next Save:", timeToSave.ToString() + " Sec");this.Repaint();if(EditorApplication.timeSinceStartup > nextSave) {var path : String [] = EditorApplication.currentScene.Split(char.Parse("/"));path[path.Length -1] = "AutoSave_" + path[path.Length-1];EditorApplication.SaveScene(String.Join("/",path));Debug.Log("Saved Scene");nextSave = EditorApplication.timeSinceStartup + saveTime;}}}


,