Generally unity is a stable program, but i do experience some problems from time to time. As discussed in another answer, an infinite loop is a particularly tricky one that you can't recover from and will take the editor down, understandably.
Anyways i wondered if there was the possibility or if such an editor script existed already that would autosave unity every so often. I wouldn't object to it doing something visible like a countdown to when you can expect a pause to happen. Some intelligence would be good if it could wait till you aren't holding down a mouse button doing anything to objects or properties.
Ideally it could autosave out to separate files than normal but i don't know how feasible this is, its not like the unity scene/project is stored in just a few files, or are they? If this is not possible just saving with the defaults would still be better than nothing.
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.
Hopefully the next person to suffer reads this Answer before restarting Unity and pressing Play again. And maybe one day Unity will pay attention to that file on restart ("Unity crashed, and in addition to sending in a bug report, here's all your work back...").
Given the amount of trouble I seem to have when running the game with the project and the scene being lost if it crashes (which is frequent for me when attaching the debugger) I have written an auto save on run - rather than on a frequency:
using UnityEngine;
using UnityEditor;
using System.Collections;
[ExecuteInEditMode]
public class AutoSave : EditorWindow
{
[MenuItem("AutoSave/Enabled")]
static void AutoSaveEnable()
{
EditorWindow.GetWindow<AutoSave>();
}
static void StateChanged ()
{
if(Application.isPlaying == false)
{
Debug.Log("SAVED SCENE AND PROJECT");
EditorApplication.SaveScene();
EditorApplication.SaveAssets();
}
}
static AutoSave()
{
EditorApplication.playmodeStateChanged += StateChanged;
}
void OnGUI()
{
GUILayout.Label("Autosave Enabled");
}
}