Recently found that unity has an old auto crash bug. The relationship between the hierarchy view game object and the game resource will be lost each time it crashes because the item is not saved. So think of auto save scene.
Originally wanted to write a script like this, but found that Wikipedia has ...
Using Unityengine; Using Unityeditor; Using System; public class Autosave:editorwindow { private bool Autosavescene =&nbs P;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) Editorwindow.getwindow (typeof (AutoSave)); savewindow.show (); } void Ongui () { guilayout.label ("Info:", Editorstyles.boldlabel); editorguilayout.labelfield ("Saving to:", "" +projectPath); editorguilayout.labelfield ("Saving scene:", "" +scenePath "); guilayout.label ("Options:", Editorstyles.boldlabel); autosavescene = Editorguilayout.begintogglegroup ("Auto Save", Autosavescene); intervalscene = Editorguilayout.intslider ("Interval (minutes)", Intervalscene, 1, 10); if (isstarted) { editorguilayout.labelfield ("Last Save:", "" +lastsavetimescene); } Editorguilayout.endtogglegroup (); &nbSp; 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 = = && DateTime.Now.Second = =) { 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 (AutoSave)); repaintsavewindow.repaint (); }}
Because this editing window must be active, you can have it attached to a window such as Project view.
For your convenience you can also save this layout for your next use.