如何让Unity自动保存场景.docx

如何让Unity自动保存场景.docx

ID:59357620

大小:63.99 KB

页数:6页

时间:2020-09-04

如何让Unity自动保存场景.docx_第1页
如何让Unity自动保存场景.docx_第2页
如何让Unity自动保存场景.docx_第3页
如何让Unity自动保存场景.docx_第4页
如何让Unity自动保存场景.docx_第5页
资源描述:

《如何让Unity自动保存场景.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、学IT技能上我学院网woxueyuan.com如何让Unity自动保存场景?我们在Unity开发过程中会发现总是会有自动崩溃的bug,而且每次崩溃可能因为没有保存项目,所以Hierarchy视图游戏对象与相关游戏资源会丢失,这个时候你就需要通过自动保存来保证你的项目进度不会丢失了。如何在Untiy中实现自动保存场景呢,我们来看一下教程。usingUnityEngine;usingUnityEditor;usingSystem;publicclassAutoSave:EditorWindow{privateboolautoSaveScene=true;

2、privateboolshowMessage=true;privateboolisStarted=false;privateintintervalScene;privateDateTimelastSaveTimeScene=DateTime.Now;privatestringprojectPath=Application.dataPath;privatestringscenePath;Unity3D

3、Cocos

4、php

5、HTML5

6、Java

7、ios

8、Android

9、C#

10、AS3

11、UI设计

12、原画设计

13、动漫美术

14、游戏策划学IT技能上我学院网woxueyu

15、an.com[MenuItem("Window/AutoSave")]staticvoidInit(){AutoSavesaveWindow=(AutoSave)EditorWindow.GetWindow(typeof(AutoSave));saveWindow.Show();}voidOnGUI(){GUILayout.Label("Info:",EditorStyles.boldLabel);EditorGUILayout.LabelField("Savingto:",""+projectPath);EditorGUILayout.LabelF

16、ield("Savingscene:",""+scenePath);GUILayout.Label("Options:",EditorStyles.boldLabel);autoSaveScene=EditorGUILayout.BeginToggleGroup("Autosave",autoSaveScene);intervalScene=EditorGUILayout.IntSlider("Interval(minutes)",intervalScene,1,10);if(isStarted){EditorGUILayout.LabelField

17、("Lastsave:",""+lastSaveTimeScene);Unity3D

18、Cocos

19、php

20、HTML5

21、Java

22、ios

23、Android

24、C#

25、AS3

26、UI设计

27、原画设计

28、动漫美术

29、游戏策划学IT技能上我学院网woxueyuan.com}EditorGUILayout.EndToggleGroup();showMessage=EditorGUILayout.BeginToggleGroup("ShowMessage",showMessage);EditorGUILayout.EndToggleGroup();}voidUpdate(){

30、scenePath=EditorApplication.currentScene;if(autoSaveScene){if(DateTime.Now.Minute>=(lastSaveTimeScene.Minute+intervalScene)

31、

32、DateTime.Now.Minute==59&&DateTime.Now.Second==59){saveScene();}}else{isStarted=false;}Unity3D

33、Cocos

34、php

35、HTML5

36、Java

37、ios

38、Android

39、C#

40、AS3

41、UI设计

42、原画设计

43、动漫美术

44、游戏策划

45、学IT技能上我学院网woxueyuan.com}voidsaveScene(){EditorApplication.SaveScene(scenePath);lastSaveTimeScene=DateTime.Now;isStarted=true;if(showMessage){Debug.Log("AutoSavesaved:"+scenePath+"on"+lastSaveTimeScene);}AutoSaverepaintSaveWindow=(AutoSave)EditorWindow.GetWindow(typeof(AutoSave)

46、);repaintSaveWindow.Repaint();}}因为这个编辑窗口必须在激活状态,所以你可以把

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。