I find this script in Unity wiki. but this script is showing me an error
error is : the type or namespace name ‘Unity Editor’ could not be found. are you missing a using directive or an assembly reference.
this code save the scene in the interval of 1 to 10 minutes
[COLOR="blue"]using[/COLOR] UnityEngine;
[COLOR="blue"]using[/COLOR] Unity Editor;
[COLOR="blue"]using[/COLOR] System;
[COLOR="blue"]public class[/COLOR] AutoSave : [COLOR="blue"]EditorWindow[/COLOR] {
[COLOR="blue"]private bool[/COLOR] autoSaveScene = [COLOR="blue"]true[/COLOR];
[COLOR="blue"]private bool[/COLOR] showMessage =[COLOR="blue"] true[/COLOR];
[COLOR="blue"]private bool[/COLOR] isStarted = [COLOR="blue"]false[/COLOR];
[COLOR="blue"] private int[/COLOR] intervalScene;
[COLOR="blue"] private[/COLOR] DateTime lastSaveTimeScene = DateTime.Now;
[COLOR="blue"] private string[/COLOR] projectPath = [COLOR="blue"]Application.dataPath[/COLOR];
[COLOR="blue"] private string[/COLOR] scenePath;
[[COLOR="blue"]MenuItem[/COLOR] ([COLOR="orange"][COLOR="red"]"Window/AutoSave"[/COLOR][/COLOR])]
[COLOR="blue"]static void[/COLOR] Init () {
AutoSave saveWindow = (AutoSave)[COLOR="blue"]EditorWindow.GetWindow[/COLOR] ([COLOR="blue"]typeof[/COLOR] (AutoSave));
saveWindow.[COLOR="blue"]Show[/COLOR]();
}
[COLOR="blue"]void OnGUI[/COLOR] () {
[COLOR="blue"] GUILayout.Label [/COLOR]("Info:",[COLOR="blue"] EditorStyles.boldLabel[/COLOR]);
[COLOR="blue"] EditorGUILayout.LabelField [/COLOR]("Saving to", ""+projectPath);
[COLOR="blue"] EditorGUILayout.LabelField[/COLOR] ("Saving scene:", ""+scenePath);
[COLOR="blue"] GUILayout.Label[/COLOR] ("Options:",[COLOR="blue"] EditorStyles.boldLabel[/COLOR]);
autoSaveScene =[COLOR="blue"] EditorGUILayout.BeginToggleGroup[/COLOR] ("Auto save", autoSaveScene);
intervalScene = [COLOR="blue"]EditorGUILayout.IntSlider[/COLOR] ("Interval (minutes)", intervalScene, 1, 10);
[COLOR="blue"] if[/COLOR](isStarted) {
[COLOR="blue"]EditorGUILayout.LabelField[/COLOR] ("Last save:", ""+lastSaveTimeScene);
}
[COLOR="#0000ff"] EditorGUILayout.EndToggleGroup[/COLOR]();
showMessage =[COLOR="#0000ff"] EditorGUILayout.BeginToggleGroup[/COLOR] ("[COLOR="#ff0000"]Show Message"[/COLOR], showMessage);
[COLOR="#0000ff"] EditorGUILayout.EndToggleGroup[/COLOR] ();
}
[COLOR="#0000ff"] void Update()[/COLOR]{
scenePath = [COLOR="#0000ff"]EditorApplication.currentScene[/COLOR];
[COLOR="#0000ff"] if[/COLOR](autoSaveScene) {
[COLOR="#0000ff"] if[/COLOR](DateTime.Now.Minute >= (lastSaveTimeScene.Minute+intervalScene) || DateTime.Now.Minute == [COLOR="#00ffff"]59[/COLOR] [B][/B] DateTime.Now.Second == [COLOR="#00ffff"]59[/COLOR]){
saveScene();
}
} [COLOR="#0000ff"]else[/COLOR] {
isStarted = [COLOR="#0000ff"]false[/COLOR];
}
}
[COLOR="#0000ff"] void [/COLOR]saveScene() {
[COLOR="#0000ff"] EditorApplication[/COLOR].Save(scenePath);
lastSaveTimeScene = DateTime.Now;
isStarted = [COLOR="#0000ff"]true[/COLOR];
[COLOR="#0000ff"] if[/COLOR](showMessage){
[COLOR="#0000ff"] Debug.Log[/COLOR]([COLOR="#ff0000"]"AutoSave saved: "[/COLOR]+scenePath+[COLOR="#ff0000"]" on "[/COLOR]+lastSaveTimeScene);
}
AutoSave repaintSaveWindow = (AutoSave)[COLOR="#0000ff"]EditorWindow.GetWindow[/COLOR] ([COLOR="#0000ff"][B]typeof[/B][/COLOR] (AutoSave));
repaintSaveWindow.[COLOR="#0000ff"]Repaint[/COLOR]();
}
}