Unity之自动保存场景
2015-07-24 17:56
561 查看
今天把http://www.xuanyusong.com/的网站又粗略浏览看有没有需要的,然后发现了“Unity插件研究院之自动保存场景”
unity老是闪退让我这种老忘保存的人情何以堪,也是吃不少亏。
贴上此代码,放到\Assets\Editor下
然后在unity界面的Window下寻找到AutoSave就可以啦
然后他就会隔了时间给你保存下还提示下(当然啦,提示也可以选择性的啦)
还有在unity界面LayerOut上还可以Save Layerout,呀呀呀,保存了
不过如果在程序运行的时候,我对程序中的模型做了改动的话,停止程序我改动的不就没有作用啦。。。。得想想怎么做,可以如果我在程序执行时对场景的模型啥的做了改动可以提示是否保存就好了。
unity老是闪退让我这种老忘保存的人情何以堪,也是吃不少亏。
using UnityEngine; using System.Collections; 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)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(); 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 && DateTime.Now.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(AutoSave)); repaintSaveWindow.Repaint(); } }
贴上此代码,放到\Assets\Editor下
然后在unity界面的Window下寻找到AutoSave就可以啦
然后他就会隔了时间给你保存下还提示下(当然啦,提示也可以选择性的啦)
还有在unity界面LayerOut上还可以Save Layerout,呀呀呀,保存了
不过如果在程序运行的时候,我对程序中的模型做了改动的话,停止程序我改动的不就没有作用啦。。。。得想想怎么做,可以如果我在程序执行时对场景的模型啥的做了改动可以提示是否保存就好了。
相关文章推荐
- unity——使用角色控制器组件+射线移动
- Unity2D动态设置SpriteRender的Sprite(Multipe)
- Unity之机器人AI
- Uniyt : 场景LoadLevel时资源和对象的处理流程
- Unity在移动平台中,文件操作路径详解
- Unity5.0新特性------动画的StateMachineBehaviours
- Unity中使用C#脚本调用JS脚本的使用方法
- 【unity】缓动插件 iTween 的使用
- <Unity3D>NGUI之HUDText的灵活使用
- Unity Mesh Collider 顶点太多报错
- UNITY3D学习笔记5
- Unity之简单的机器人AI状态改变
- [UnityUI]一些有趣的UI例子
- unity Bug(1)UnityEditor.UI.dll' is in timestamps but is not known in assetdatabase
- 浅尝Unity 3D的Asset Bundle知识(五)-----缓存利用篇
- Unity3D教程:实现基于Socket通讯的公共聊天室
- Unity3d摄影机晃动特效【C#脚本】
- Unity 鼠标拖动场景内的物体
- Unity官方教程学习笔记之Roll A Ball篇---(二)创建地面
- Unity3D学习笔记-----2015-07-24(GUI---01)