Using unityengine;
using unityeditor; using System; public class AutoSave : editorwindow { private bool autosavescene = true; private bool showmessage = true; private bool isstarted = false; private int intervalscene; Private datetime lastsavetimescene = datetime. Now; Private string projectpath = application. DataPath; Private string scenepath; [MenuItem ("Window/autosave")] static void Init () { AutoSave savewindow = (autosave) EditorWindowgetwindow (typeof< Span class= "crayon-h" > (autosave Savewindow. Show(); } void Ongui () { GUILayoutlabel ( "Info:" Span class= "Crayon-sy" >, editorstyles.< Span class= "crayon-v" >boldlabel EditorGUILayout< Span class= "Crayon-sy". labelfield (, " +< Span class= "crayon-v" >projectpath EditorGUILayout< Span class= "Crayon-sy". labelfield (, " + scenepath) GUILayoutlabel ( "options:" Span class= "Crayon-sy" >, editorstyles.< Span class= "crayon-v" >boldlabel autoSaveScene< Span class= "crayon-h" > = editorguilayout< Span class= "Crayon-sy". begintogglegroup (, autosavescene intervalScene< Span class= "crayon-h" > = editorguilayout< Span class= "Crayon-sy". intslider (, intervalscene, 110 if(isstarted) { editorguilayout. LabelField ("Last Save:", " "+lastsavetimescene); } editorguilayout. Endtogglegroup(); showmessage = editorguilayout. Begintogglegroup ("Show Message", showmessage); editorguilayout. Endtogglegroup (); } void Update(){ scenepath = editorapplication. Currentscene; if(autosavescene) { If(Datetime.Now.Minute >= (Lastsavetimescene.minute+intervalscene | | datetime. Now. Minute == 59 && DateTimenow. Second == 59{ savescene(); } } else { isstarted = false; } } void savescene() { editorapplication. Savescene(scenepath); lastsavetimescene = DateTime. Now; isstarted = true; if(showmessage){ Debug. Log("AutoSave Saved:"+Scenepath+"on"+lastsavetimescene); } AutoSave repaintsavewindow = (autosave) EditorWindow getwindow (typeof< Span class= "crayon-h" > (autosave Repaintsavewindow. Repaint(); }}
Note: 1. Script as above, save in the assets is done. To set the time interval for autosave, the option is in AutoSave under the Windows drop-down menu
2. It is now known that each project has to be installed with a script. (A little awkward)
Unity Project Auto-Save script