Unity场景自动保存工具
来源:互联网 发布:马鞍山电视网络大学 编辑:程序博客网 时间:2024/06/06 07:46
Unity场景自动保存工具
难得闲下来,好好整理一下,今天主要分享一下在Unity中,开启场景的自动保存功能,是从网上买的源码中找到的,还是挺有用的,这样就算突然断电或者忘记保存了,不会导致太严重的后果,因为可以设置1-10分钟自动保存一次。
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(); }}
将些脚本放置到Unity工程中的Editor文件夹中,然后点击window下的AutoSave就可以进行方便的自动保存了。
阅读全文
0 0
- Unity场景自动保存工具
- unity 场景自动保存
- Unity自动保存场景脚本
- Unity插件研究院之自动保存场景
- Unity插件研究院之自动保存场景
- Unity编辑器扩展(自动保存当前打开的场景)
- Unity跨场景保存数据
- unity自动保存项目
- unity自动保存项目
- Unity利用Xml和Json保存场景
- Unity自动打包工具
- Unity自动打包工具
- Unity 3D自动保存项目
- 改变unity场景的图片比例保存到xml当中
- 定制自己的Unity场景编辑工具界面(一)
- Unity之AssetBundle自动打包工具
- Unity导出xcode自动配置工具
- 【Unity插件】自动保存备份插件,极其容易失去响应
- 事件过滤器
- 仿QQ语言变声功能
- Qstring转char*
- JS基础 面向对象方式写选项卡
- load命令
- Unity场景自动保存工具
- utf8_general_ci、utf8_unicode_ci和utf8_bin的区别
- arm下gdb调试和杀线程以及make编译
- Android自定义View详解
- Android自定义圆环,取区域
- 学习kotlin第八天_接口、可见性修饰符、扩展
- JDBC的ResultSet接口(查询操作)、PreparedStatement接口增删改查(转载)
- 王子和公主 (uva10635)
- 【状态】:今日踽踽独行,他日化蝶归去