- Home /
Auto save every five minutes?
Hi.
Most of us know the 3.4 ver. of Unity is slightly less stable than it really should but, for us/me there is nothing we/I can do about it. So I was thinking about the next best; an auto save function within Unity.
Since yesterday evening I was on a roll and had really fun creating my game but, as stupid as I am(I blame no other than myself) I had forgotten to save for hours, and of course the inevitable happens. Unity crashes and I almost burst into tears.
So after a night of banging my head against the wall I ask you. Is it possible to have a auto save function inside Unity so it saves every 5 minutes or so? Can that be done by scripts or...?
Thank you for your time.
Is it disrespectful to say that I laughed a little? But I did "Banging my head against the wall". No disrespect though. I am sorry for your loss of work.
But 3.4 is less stable and Unity could benefit from an auto save function. And it will properly save my butt sooner or later. I do not know if one exists already, though.
It could be cool if you could access the save function from script.
@OrangeLightning No, you did not offend me or any of that jazz. :) There is nothing I can do about it so there is really no reason to be mad. But it dose slightly annoy me.
Good news: we can expect a more stable version, 3.4.1, to come out in the co$$anonymous$$g week. :)
@$$anonymous$$athias in between my spam$$anonymous$$g of bug reports for all the different issues in 3.4 I asked them if/when they expected a version more stable on Windows to be released. They told me 'probably' in the week that is now this week.
Answer by YikYikHeiHei · Aug 20, 2011 at 08:04 AM
OBSOLETE:
Please see that
http://www.unifycommunity.com/wiki/index.php?title=AutoSave
EDIT:
https://gist.github.com/dustingraham/3e5367a12acba1eb013cc35e187e3898
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
public class AutosaveOnRun
{
static AutosaveOnRun()
{
EditorApplication.playmodeStateChanged = () =>
{
if(EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
{
Debug.Log("Auto-Saving scene before entering Play mode: " + EditorApplication.currentScene);
EditorApplication.SaveScene();
EditorApplication.SaveAssets();
}
};
}
}
This is not working for me in Unity 4.2. It causes Unity to crash every time I try to run the script (via Window > Autosave).
For autosave on Play functionality add this script to ad "Editor" folder:
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
public class AutosaveOnRun
{
static AutosaveOnRun()
{
EditorApplication.playmodeStateChanged = () =>
{
if(EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
{
Debug.Log("Auto-Saving scene before entering Play mode: " + EditorApplication.currentScene);
EditorApplication.SaveScene();
EditorApplication.SaveAssets();
}
};
}
}
Unity 2017.4 says that is deprecated, here is an updated version that works for me: https://gist.github.com/dustingraham/3e5367a12acba1eb013cc35e187e3898 note it saves all open scenes.
Answer by Eric5h5 · Aug 20, 2011 at 08:05 AM
Unity auto-saves whenever you hit play. If it crashes, retrieve the __EditModeScene from the Temp folder (before you load Unity again) and rename it to whatever your scene file is called.
Unity 4.3 doesnt autosave when you hit play, I just lost 2 hours of work due to crash. Wish I had have known this little tid-bit of info before I reopened Unity again right after. I thought by 4.3 autosave would be a standard feature, I guess not.
Unity doesn't autosave your own scene file on play but it does save a copy... unfortunately it nukes this temporary copy when you start Unity again.
For a real autosave on play that saves your permanent scene file, add this script to an "Editor" folder:
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
public class AutosaveOnRun
{
static AutosaveOnRun()
{
EditorApplication.playmodeStateChanged = () =>
{
if(EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
{
Debug.Log("Auto-Saving scene before entering Play mode: " + EditorApplication.currentScene);
EditorApplication.SaveScene();
EditorApplication.SaveAssets();
}
};
}
}
Your answer
Follow this Question
Related Questions
input .lzma too short 0 Answers
PlayerPrefs not working? 1 Answer
IsolatedStorageException: Could not find a part of the path 1 Answer
Port Project Setting TO Another Project 0 Answers
Questions about XML save/load 0 Answers