Unity自动保存场景脚本
来源:互联网 发布:b站语梨 知乎 编辑:程序博客网 时间:2024/06/06 06:10
Unity自动保存场景脚本
原文:http://wiki.unity3d.com/index.php/AutoSave
AutoSave.cs
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)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 目录下,这时候会在Windows菜单下面添加一个子菜单autosave
激活 Windows->autosave
这时候会弹出AutoSave窗口
可以设置保存的频率 , 是否在控制台打印保存Log等
0 0
- Unity自动保存场景脚本
- unity 场景自动保存
- Unity场景自动保存工具
- Unity插件研究院之自动保存场景
- Unity插件研究院之自动保存场景
- Unity编辑器扩展(自动保存当前打开的场景)
- Unity跨场景保存数据
- unity自动保存项目
- unity自动保存项目
- unity场景打包脚本BuildSceneEditor
- unity 场景NPC触发漫游和间隔时间自动显示对话在人物上方的简单脚本!
- Unity利用Xml和Json保存场景
- Unity 脚本 自动添加 脚本信息
- Unity 脚本 自动添加 脚本信息
- Unity 3D自动保存项目
- 改变unity场景的图片比例保存到xml当中
- Unity 3D视频播放器场景C#脚本
- Unity查找脚本被哪些Perfab或场景引用
- 利用AIDL来实现由Binder进行进程间通信(IPC)
- Multi-label learning 第一周
- 如何定位和解决Andorid的内存溢出问题
- MyEclipse快捷键大全
- 黑马程序员_OC学习日记1
- Unity自动保存场景脚本
- 操作文件目录
- 什么是P问题、NP问题和NPC问题
- 程序员,这12个问题让经理比你痛苦多了
- Java基础知识 三 (运算符、键盘录入、函数(方法))
- opencv中的saturate_cast数据溢出保护
- 启动tomcat时报 Exception in thread http-apr-8080-exec-11、9等错误
- android 版本兼容 @TargetApi
- 有关UCF解析器系统架构的设计