当前位置:   article > 正文

每天学学_0_now.minuteof

now.minuteof

System.DateTime.Now

系统时间

----------------------------------

EditorApplication.currentScene

static var currentScene :string

Description

The path of the scene that the user has currently open (Read Only)

----------------------

 EditorApplication.SaveScene(scenePath);

---------------------------

 

  1. using UnityEngine;
  2. using UnityEditor;
  3. using System;
  4. public class AutoSave : EditorWindow {
  5. private bool autoSaveScene = true;
  6. private bool showMessage = true;
  7. private bool isStarted = false;
  8. private int intervalScene;
  9. private DateTime lastSaveTimeScene = DateTime.Now;
  10. private string projectPath = Application.dataPath;
  11. private string scenePath;
  12. [MenuItem ("Window/AutoSave")]
  13. static void Init () {
  14. AutoSave saveWindow = (AutoSave)EditorWindow.GetWindow (typeof (AutoSave));
  15. saveWindow.Show();
  16. }
  17. void OnGUI () {
  18. GUILayout.Label ("Info:", EditorStyles.boldLabel);
  19. EditorGUILayout.LabelField ("Saving to:", ""+projectPath);
  20. EditorGUILayout.LabelField ("Saving scene:", ""+scenePath);
  21. GUILayout.Label ("Options:", EditorStyles.boldLabel);
  22. autoSaveScene = EditorGUILayout.BeginToggleGroup ("Auto save", autoSaveScene);
  23. intervalScene = EditorGUILayout.IntSlider ("Interval (minutes)", intervalScene, 1, 10);
  24. if(isStarted) {
  25. EditorGUILayout.LabelField ("Last save:", ""+lastSaveTimeScene);
  26. }
  27. EditorGUILayout.EndToggleGroup();
  28. showMessage = EditorGUILayout.BeginToggleGroup ("Show Message", showMessage);
  29. EditorGUILayout.EndToggleGroup ();
  30. }
  31. void Update(){
  32. scenePath = EditorApplication.currentScene;
  33. if(autoSaveScene) {
  34. if(DateTime.Now.Minute >= (lastSaveTimeScene.Minute+intervalScene) || DateTime.Now.Minute == 59 && DateTime.Now.Second == 59){
  35. saveScene();
  36. }
  37. } else {
  38. isStarted = false;
  39. }
  40. }
  41. void saveScene() {
  42. EditorApplication.SaveScene(scenePath);
  43. lastSaveTimeScene = DateTime.Now;
  44. isStarted = true;
  45. if(showMessage){
  46. Debug.Log("AutoSave saved: "+scenePath+" on "+lastSaveTimeScene);
  47. }
  48. AutoSave repaintSaveWindow = (AutoSave)EditorWindow.GetWindow (typeof (AutoSave));
  49. repaintSaveWindow.Repaint();
  50. }
  51. }


 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/141715
推荐阅读
相关标签
  

闽ICP备14008679号