Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AUTO-SAVE AUTO-SAVE!!!! Please

Discussion in 'Wish List' started by nikko, Apr 24, 2009.

  1. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
    I've just lost - again - 1 hours of work because Unity crashed after I move a light!

    Why not saving the project in background every time we create a new gameobject or we change something significant. Just a check-box to enable this feature or not (in case some have projcets too big to be saved in background...

    Please!!! I'm fed up loosing time and I can't save every 5 min!!!
     
    Asimaruk likes this.
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    Why not? Apple-S (or Ctrl-S) is not hard or time-consuming.

    Not that autosave would be a bad thing - but it does seem that you're being mad at UT because you forgot to save.
     
  3. Scrat

    Scrat

    Joined:
    Apr 20, 2008
    Posts:
    316
    lol I'm with StarManta here. I can understand you don't save for like 10 minutes but 1 hour... That's just looking for problems :p

    Especially you say "again". Don't you learn from your mistakes? ;)
     
  4. tewe76

    tewe76

    Joined:
    Mar 14, 2009
    Posts:
    52
    Yeah, i also think it's your fault :p
    But, any way, and Option is always good. Many softwares have this option, why not Unity?
    It has to be easy to implement, no? Basically a timer which calls the save function.
     
  5. Spacemonkey

    Spacemonkey

    Joined:
    Oct 24, 2008
    Posts:
    89
    Mm, haven't you folks ever experienced being so sucked up into what you're doing that you forget to save?

    Anyhows, thumbs-up for auto-save! Every 15 minutes or something would be good.
     
    alphadogware likes this.
  6. Scrat

    Scrat

    Joined:
    Apr 20, 2008
    Posts:
    316
    Lol yeah it actually happened to me (I lost quite some work), but now I always save.... always :p

    I don't know, maybe it would be better to have an option that actually recovers the scene when it crashes. Some software have this option. I guess it involves more work but that'd be more useful.
     
  7. tewe76

    tewe76

    Joined:
    Mar 14, 2009
    Posts:
    52
    Also from me, but OPTIONAL autosave! I usually like to decide WHEN to save my work.
     
    alphadogware likes this.
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Unity already has auto-save...any time you enter play mode, the current scene is backed up in the temp folder as "__EditModeScene". This can be moved and renamed if necessary, and used like any other ".unity" scene file.

    --Eric
     
  9. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
    Damn, that's an interesting information! Thanks!
     
  10. ElmarKleijn

    ElmarKleijn

    Joined:
    May 11, 2009
    Posts:
    87
    I would love an auto-save aswell. The _editmodescene file does not always stay when Unity crashes, because the temp directory is removed.

    A simple copy/rename of the _editmodescene file "on play" would be enough. And not stored in the temp directory.
     
  11. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
    WTF!!!

    I was working on this scene and after having done a tons of changes, when I was so proud having finally found the right lightning I run my project :

    CRASH

    I got ballistic and almost destroyed my mouse (I love animals).

    But I remember, there is a thread where.... I come back here to find the trick about __editmodescene... got the file, load it...

    It WORKS!!! Oh my god! Thanks!!!
     
  12. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
    Those of you on a Mac can use AppleScript to do auto-saves (sort of). Unity doesn't appear to support AppleScript directly, but you can still control it via keystrokes.

    Something like this should work... use at your own risk, it hasn't been properly tested!

    Code (csharp):
    1. --Prompts user to save Unity every 10 minutes
    2. --Not tested, use at your own risk!
    3. set saveTime to 600 --number of seconds between saves
    4. tell application "Unity" to activate
    5. repeat while true
    6.     delay saveTime
    7.     tell application "System Events" to (name of processes) contains "Unity"
    8.     set unityRunning to result
    9.     if not unityRunning then tell me to quit --script quits if Unity not running
    10.     activate me
    11.     display dialog "Save Unity?" buttons {"Yes", "No"} default button 1
    12.     if the button returned of the result is "Yes" then
    13.         tell application "Unity" to activate
    14.         delay 0.2
    15.         tell application "System Events" to set frontApp to name of process 1 whose frontmost is true
    16.         if frontApp is equal to "Unity" then tell application "System Events" to keystroke "s" using command down
    17.     else
    18.         tell application "Unity" to activate
    19.     end if
    20. end repeat
    Plug the code into Apple's Script Editor and save it as an application. Click on it to launch both the auto-save script and Unity.
     
  13. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    Unity 2.5.1 comes with a number of editor stability enhancements. Just go download the Unity Editor again for their website and it will be 2.5.1.

    But I agree with having more options, including Auto-save.
     
  14. SilentWarrior

    SilentWarrior

    Joined:
    Aug 3, 2010
    Posts:
    107
    I actually searched google for unity auto-save.

    It has crashed few times already for me, and I hate losing work, even if its just 5 minutes of work. Drives me mad, and normally, after losing work, i tend go go berzerk and quit unity altogether for a few hours...
     
  15. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Here:

    Save this to a file named "AutoSave.cs" inside a folder called "Editor".

    To access Edit -> Project Settings -> AutoSave

    Be sure to read the disclaimer information to ensure that you are using it right!

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using System.Collections.Generic;
    5.  
    6. public class AutoSave : EditorWindow
    7. {
    8.     public string relativeSavePath = "Assets/";
    9.     public string autoSaveFileName = "AutoSave";
    10.     public int secondsBetweenSaves = 600;
    11.  
    12.     [MenuItem("Edit/Project Settings/AutoSave")]
    13.     static void Init()
    14.     {
    15.         // Get existing open window or if none, make a new one:
    16.         AutoSave window = (AutoSave)EditorWindow.GetWindow(typeof(AutoSave));
    17.         window.minSize = new Vector2(225, 21);
    18.         window.Show();
    19.     }
    20.  
    21.     float nextsave = 0;
    22.     int timeLeft = 0;
    23.     bool showDisclaimer = true;
    24.     bool showDebug = true;
    25.     bool toggleVisible = false;
    26.     Vector2 winPosition = Vector2.zero;
    27.     Vector2 disPosition = Vector2.zero;
    28.  
    29.     void OnGUI()
    30.     {
    31.         if (GUILayout.Button("Created By ReverieInteractive"))
    32.         {
    33.             Application.OpenURL("www.reverieinteractive.com");
    34.         }
    35.         GUI.color = Color.white;
    36.         GUI.contentColor = Color.white;
    37.         winPosition = GUILayout.BeginScrollView(winPosition);
    38.         if (showDisclaimer = EditorGUILayout.Foldout(showDisclaimer, "Disclaimer and Information"))
    39.         {
    40.             GUI.contentColor = Color.yellow;
    41.             disPosition = GUILayout.BeginScrollView(disPosition);
    42.             GUILayout.TextArea("IMPORTANT: The autosave will only save scenes if this window is OPEN and VISIBLE. If you hide this window, the autosave WILL NOT WORK!\n\n-------HELP INFO------\n\n\"Save Iteration\" - Seconds between saves (600 = saves every 10 min)\n\n\"File Name\" - The name of the AutoSave file (DONT name this the same as your opened scene)\n\n\"Relative Path\" - The path (from your projects folder up) to where the file is saved\n\n\"Apply Instantly\" - Applies settings and saves the scene without having to wait for the next save cycle");
    43.             GUILayout.EndScrollView();
    44.         }
    45.         GUI.contentColor = Color.white;
    46.         if (toggleVisible = EditorGUILayout.Foldout(toggleVisible, "AutoSave Settings"))
    47.         {
    48.             secondsBetweenSaves = EditorGUILayout.IntField("Save Iteration", secondsBetweenSaves);
    49.             autoSaveFileName = EditorGUILayout.TextField("File Name", autoSaveFileName);
    50.             relativeSavePath = EditorGUILayout.TextField("Relative Path", relativeSavePath);
    51.             showDebug = EditorGUILayout.Toggle("Show Warning", showDebug);
    52.         }
    53.  
    54.         if(GUILayout.Button("Apply Instantly"))
    55.         {
    56.             SaveScene();
    57.         }
    58.         EditorGUILayout.LabelField("Next Save:", timeLeft + " Seconds");
    59.         GUILayout.EndScrollView();
    60.     }
    61.  
    62.     void OnInspectorUpdate()
    63.     {
    64.         timeLeft = (int)(nextsave - Time.realtimeSinceStartup);
    65.         this.Repaint();
    66.     }
    67.  
    68.     void Update()
    69.     {
    70.         if (Time.realtimeSinceStartup >= nextsave)
    71.         {
    72.             SaveScene();
    73.         }
    74.     }
    75.  
    76.     void SaveScene()
    77.     {
    78.         EditorApplication.SaveScene(relativeSavePath + autoSaveFileName + ".unity");
    79.         nextsave = Time.realtimeSinceStartup + secondsBetweenSaves;
    80.  
    81.         if(showDebug)
    82.             Debug.LogWarning("Saved scene: " + relativeSavePath + autoSaveFileName + ".unity");
    83.     }
    84. }
    85.  
    86.  
     
    SongU likes this.
  16. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    Lol, I have gotten into the habit of saving after changing any tiny little thing.
     
  17. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    lol. Well this is nice script because it quietly runs while you work. I used it all night last night and I gotta say I'm pretty pleased with how well its been working.


    Let me know how you like it of you end up using it!

    Jake
     
  18. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    If such a thing occurs I definitely will.
     
  19. Mabluz

    Mabluz

    Joined:
    Nov 12, 2010
    Posts:
    1
    Thank you so much :D
    This is a life saver for my blue screens.
     
  20. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    if you get blue screens you either need to check your hardware, its drivers or your security solution as only these 3 things can cause blue screens.
    If they primarily happen when using unity, I would commonly blame the gpu as it gets pushed rather hard
     
  21. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    There are some bugs with that version of the autosaver.. I will try to get a better one uploaded to my site for anyone who is interested by the end of the weekend.

    Jake
     
    Connor_Epic likes this.
  22. VCCGeek

    VCCGeek

    Joined:
    Nov 17, 2009
    Posts:
    89
    To be fair, sometimes it's not Unity that's crashing, but rather that I've gone and done something boneheaded in my code that made it go into an endless loop. I guess the solution for that might be not just autosave, but a function that allows you to stop execution in the event of a runaway process.

    Vote up for autosave anyway. :)
     
  23. monozoo

    monozoo

    Joined:
    Mar 11, 2011
    Posts:
    10
    Not sure if everybody allready has a proper auto-save solution.
    Just in case I would like to recommend our Auto Project Backup, which you can find in the asset store.
     
  24. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    287
    Well, it was Unity that crashed. The continuing lack of auto-save, plus the persistence of two different "Save" menu items (Save Scene vs. Save Project) continues to be a blight on the Unity UI to this day.
     
  25. ChrisYummi

    ChrisYummi

    Joined:
    Jul 5, 2012
    Posts:
    8
    Very funny thread with people suggesting users become computers and autosave themselves every 10 minutes! Do they really think we don't have better things to do than typing save just in case. Unity is all about letting you focus on creating games so why doesn't it automate backing up too?

    The _EditModeScene tip is INCREDIBLY useful but unfortunately when I just did a search I had already restarted Unity and it must blitz it on startup. Take care with the new particle system as it has lost me work twice in as many weeks. All they need to do is check if this file hasn't been tidied up on a safe shutdown and offer to open it up. Not perfect but would really help.

    The computer is the thing that can do things systematically every n minutes - that's just what computers are for! This and a full Undo system should be fundamental to any good software package.
     
  26. Wolf5370

    Wolf5370

    Joined:
    Aug 31, 2012
    Posts:
    10
    I agree (although its an old thread - its still the case in 3.5 today). The problem with relying on Cmd/Ctrl - S is that sometimes Unity screws up the scene file and if the temp directory is empty - you lose the scene (and often terain) completely. One cause of this is accidently hitting build in MonoDev instead of save (common if you use VS a lot! - personally I unmapped all build/run/debug key combos in Mono - but I only use it for Unity I use full VS for XNA/non-unity Windows coding) - doesn't always screw up scene, but does sometimes.

    A simple auto-save to a set folder (other than temp!) - preferably tailorable to number of online back-ups and interval - would be a boon for the annoyance of losing hours of work that has been manually saved often!