system
1
So I got on my computer today to work on my game. I loaded up the scene. Everything in the hierarchy is GONE. What happened, and can I get it back?
EDIT:
How do I load a backup file?
Waz
2
It’s absolutely no substitute for keeping backups (I run mine automatically at noon every day, backed to a RAID1 NAS, the drives of which I replace annually, and even with that I get uneasy)… but here’s my auto-save script:
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
class AutoSave
{
static AutoSave()
{
EditorApplication.update += Save;
}
static double nextSave = 0.0;
static double interval = 10.0;
static void Save()
{
if (EditorApplication.timeSinceStartup >= nextSave && !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying && EditorApplication.currentScene != "") {
nextSave = EditorApplication.timeSinceStartup + interval;
if (System.IO.File.Exists(EditorApplication.currentScene+"-2"))
FileUtil.ReplaceFile(EditorApplication.currentScene+"-2",EditorApplication.currentScene+"-3");
if (System.IO.File.Exists(EditorApplication.currentScene+"-1"))
FileUtil.ReplaceFile(EditorApplication.currentScene+"-1",EditorApplication.currentScene+"-2");
FileUtil.ReplaceFile(EditorApplication.currentScene,EditorApplication.currentScene+"-1");
EditorApplication.SaveScene(EditorApplication.currentScene);
EditorApplication.SaveAssets();
//Debug.Log("Auto-saved "+System.DateTime.Now);
}
}
}
Put that in Editor/AutoSave.cs and you’ll get 3 backup scenes regardless of the bugginess of a particular Unity release.