Create a new editor script named AutoSave, and put it under Assets/editor.
1 usingSystem;2 usingUnityeditor;3 usingunityeditor.scenemanagement;4 usingUnityengine;5 usingunityengine.scenemanagement;6 7 Public classAutosave:editorwindow8 {9 Private BOOL_autosavescene;Ten Private BOOL_showmessage; One Private BOOL_isstarted; A Private int_intervalscene; - PrivateDateTime _lastsavetimescene =DateTime.Now; - the Private ReadOnly string_projectpath =Application.datapath; - Private string_scenepath; - -[MenuItem ("Window/autosave")] + Private Static voidInit () - { +AutoSave Savewindow = (AutoSave) GetWindow (typeof(AutoSave)); A savewindow.show (); at } - - Private voidOngui () - { -Guilayout.label ("Info:", Editorstyles.boldlabel); -Editorguilayout.labelfield ("Saving to:",""+_projectpath); inEditorguilayout.labelfield ("Saving scene:",""+_scenepath); -Guilayout.label ("Options:", Editorstyles.boldlabel); to_autosavescene = Editorguilayout.begintogglegroup ("Auto Save", _autosavescene); +_intervalscene = Editorguilayout.intslider ("Interval (minutes)", _intervalscene,1,Ten); - if(_isstarted) the { *Editorguilayout.labelfield ("Last Save:",""+_lastsavetimescene); $ }Panax Notoginseng Editorguilayout.endtogglegroup (); -_showmessage = Editorguilayout.begintogglegroup ("Show Message", _showmessage); the Editorguilayout.endtogglegroup (); + } A the Private voidUpdate () + { -_scenepath =scenemanager.getactivescene (). path; $ if(_autosavescene) $ { - if(DateTime.Now.Minute >= (_lastsavetimescene.minute + _intervalscene) | | -DateTime.Now.Minute = = -&& DateTime.Now.Second = = -) the { - Savescene ();Wuyi } the } - Else Wu { -_isstarted =false; About } $ - } - - Private voidSavescene () A { + Editorscenemanager.savescene (Scenemanager.getactivescene ()); the_lastsavetimescene =DateTime.Now; -_isstarted =true; $ if(_showmessage) the { theDebug.Log ("AutoSave Saved:"+ _scenepath +" on"+_lastsavetimescene); the } theAutoSave Repaintsavewindow = (AutoSave) GetWindow (typeof(AutoSave)); - repaintsavewindow.repaint (); in } the}
In Window/autosave you can open the Panel, which automatically identifies the project path and saves the scene on a timed basis.
Unity Automatic Scene Save script