Version: 2017.1
public static double timeSinceStartup ;

描述

自编辑器启动以来经过的时间。(只读)

此属性包含自编辑器启动以来经过的时间(单位:秒)。 与 Time.realtimeSinceStartup 不同,此属性不会在启动播放模式时重置。

另请参阅:Time.realtimeSinceStartup


Simple Editor Window that saves each 300 seconds the current scene.

/ Simple editor window that autosaves the working scene
// Make sure to have this window opened to be able to execute the auto save.

using UnityEngine; using UnityEditor; using UnityEngine.SceneManagement; using UnityEditor.SceneManagement;

public class SimpleAutoSave : EditorWindow { static float saveTime = 300.0f; static double nextSave = 0;

static int autoSaveLabel = 1;

[MenuItem("Examples/Simple autoSave")] static void Init() { SimpleAutoSave window = (SimpleAutoSave)GetWindowWithRect( typeof(SimpleAutoSave), new Rect(0, 0, 160, 60)); window.Show(); }

void OnGUI() { EditorGUI.LabelField(new Rect(10, 10, 80, 20), "Save Each:"); EditorGUI.LabelField(new Rect(80, 10, 80, 20), saveTime + " secs");

double timeToSave = nextSave - EditorApplication.timeSinceStartup;

EditorGUI.LabelField(new Rect(10, 30, 80, 20), "Next Save:"); EditorGUI.LabelField(new Rect(80, 30, 80, 20), timeToSave.ToString("N1") + " secs");

this.Repaint();

// when time has reach zero then save the scene if (EditorApplication.timeSinceStartup > nextSave) { Scene scene = SceneManager.GetActiveScene(); string name = scene.name + autoSaveLabel;

EditorSceneManager.SaveScene(scene, "Assets/wibble/" + name + ".unity", true); autoSaveLabel = autoSaveLabel + 1; nextSave = EditorApplication.timeSinceStartup + saveTime;

Debug.Log("Saved Scene: " + name); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961