Save scene automatically

Source: Internet
Author: User

1 usingUnityengine;2 usingUnityeditor;3 usingSystem;4  5  Public classAutosave:editorwindow {6  7     Private BOOLAutosavescene =true;8     Private BOOLShowMessage =true;9     Private BOOLisstarted =false;Ten     Private intIntervalscene; One     PrivateDateTime Lastsavetimescene =DateTime.Now; A   -     Private stringProjectPath =Application.datapath; -     Private stringScenepath; the   -[MenuItem ("Window/autosave")] -     Static voidInit () { -AutoSave Savewindow = (AutoSave) Editorwindow.getwindow (typeof(AutoSave)); + savewindow.show (); -     } +   A     voidOngui () { atGuilayout.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,Ten); in         if(isstarted) { -Editorguilayout.labelfield ("Last Save:",""+lastsavetimescene); to         } + Editorguilayout.endtogglegroup (); -ShowMessage = Editorguilayout.begintogglegroup ("Show Message", showmessage); the Editorguilayout.endtogglegroup (); *     } $  Panax Notoginseng     voidUpdate () { -Scenepath =Editorapplication.currentscene; the         if(autosavescene) { +             if(DateTime.Now.Minute >= (lastsavetimescene.minute+intervalscene) | | DateTime.Now.Minute = = -&& DateTime.Now.Second = = -){ A Savescene (); the             } +}Else { -isstarted =false; $         } $   -     } -   the     voidSavescene () { - Editorapplication.savescene (scenepath);WuyiLastsavetimescene =DateTime.Now; theisstarted =true; -         if(showmessage) { WuDebug.Log ("AutoSave Saved:"+scenepath+" on"+lastsavetimescene); -         } AboutAutoSave Repaintsavewindow = (AutoSave) Editorwindow.getwindow (typeof(AutoSave)); $ repaintsavewindow.repaint (); -     } -}

Save scene automatically

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.