博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Unity自动保存场景脚本
阅读量:6946 次
发布时间:2019-06-27

本文共 1216 字,大约阅读时间需要 4 分钟。

1 自动保存场景脚本,是一个js脚本,放到Editor文件夹下,在任务栏的Window下就可以看到SimpleSave了,点击后会打开一个小窗口,这个窗口必须一直存在前台,关闭就会停止.

saveTime : 是30秒保存一次

import UnityEditor;class SimpleAutoSave extends EditorWindow {    var saveTime : float = 30;    var nextSave : float = 0;    @MenuItem("Window/SimpleSave")    static function Init() {        var window : SimpleAutoSave =            EditorWindow.GetWindowWithRect(                SimpleAutoSave,                Rect(0,0,165,40));        window.Show();    }    function OnEnable(){       nextSave = EditorApplication.timeSinceStartup + saveTime;    }    function OnGUI() {         EditorGUILayout.LabelField("Save Each:", saveTime + " Secs");         var timeToSave : int = nextSave - EditorApplication.timeSinceStartup;         EditorGUILayout.LabelField("Next Save:", timeToSave.ToString() + " Sec");         this.Repaint();        if(EditorApplication.timeSinceStartup > nextSave) {            var path = EditorApplication.currentScene;            try{             EditorApplication.SaveScene(path);            }            catch(error){            }                       nextSave = EditorApplication.timeSinceStartup + saveTime;        }    }}复制代码

转载于:https://juejin.im/post/5b3ac9626fb9a024a84166a1

你可能感兴趣的文章
Python 17.3 WSGI接口
查看>>
mysql日常小练习-20171012
查看>>
将Python脚本打包成可执行文件
查看>>
Linux motd详解
查看>>
根据status 对mysql进行性能优化
查看>>
java之CountDownLatch看看笔记
查看>>
Implement_strStr --leetcode
查看>>
我的友情链接
查看>>
centos 7设置smtp发送163邮件
查看>>
我的友情链接
查看>>
文件服务器之Branchcache分布式缓存
查看>>
我的友情链接
查看>>
Java设计模式百例 - 抽象工厂模式
查看>>
依赖倒置原则 DIP(Dependence Inversion Principle)
查看>>
智能硬件的简单剖析
查看>>
三种不同的交换机mac端口绑定模式的区别
查看>>
JupyterLab安装地图插件
查看>>
教程:Akismet获取API KEY的方法
查看>>
实现 Ctrl+Enter 快捷发表留言功能
查看>>
Linux内核的Makefile和kconfig解读
查看>>