- Home /
Save Scene with Every Change - Help!
Hello everyone, I have this script from Unity Reference. it works fine but saves every min. how can i make it save every time a change is been made? for example if you pickup an item, after loading, the item not to be there anymore. So i can keep the changes in the scene.
class SimpleSaveScene extends EditorWindow{
var saveTime : float = 300;
var nextSave : float = 0;
@MenuItem ("Simple autoSave")
static function Init(){
var window : SimpleSaveScene =
EditorWindow.GetWindowWithRect(
SimpleSaveScene,
Rect(0,0,165,40));
window.Show();
}
function OnGUI(){
EditorGUILayout.LabelField("Save Each:", saveTime + "Secs");
var timeToSave : int = nextSave - EditorApplication.timeSinceStartup;
EditorGUILayout.LabelField("Next Save:",timeToSave.ToString()+"Secs");
this.Repaint();
if(EditorApplication.timeSinceStartup > nextSave){
var path : String [] = EditorApplication.currentScene.Split(char.Parse("/"));
path[path.Length -1] = "Autosave_" + path[path.Length-1];
EditorApplication.SaveScene(String.Join("/",path), true);
Debug.Log("Saved Scene");
nextSave = EditorApplication.timeSinceStartup + saveTime; } }
}
Thank you in advance and for your time
Answer by PAEvenson · Sep 11, 2012 at 01:40 PM
Maybe this can help you...http://docs.unity3d.com/Documentation/ScriptReference/GUI-changed.html?from=EditorUtility