Hi my question is very simple. I would like to create a plugin where unity saves each time I press play in the editor. Or each N minutes …
Thats all. Is this posible? Is there a way to create a function where I can call a saveScene() method after certain time or something like that?
My job is to test different plugins to see if they improve our development. But I always lose work because the plugins I test crashes and unity needs to be closed. So I would like to know a way to improve this looses.
Based on the information DaveA gave me I did this:
using UnityEngine;
using UnityEditor;
public class SaveOnPlay : EditorWindow
{
bool saved = false;
//
// Add menu named "Enable Save On Play" to the Window menu
//
[MenuItem ("Window/Enable Save On Play")]
static void Init ()
{
//
// Get existing open window or if none, make a new one:
//
SaveOnPlay window = (SaveOnPlay) EditorWindow.GetWindow (typeof (SaveOnPlay));
}
void Update()
{
if(EditorApplication.isPlayingOrWillChangePlaymode)
{
if(!saved)
{
saved = true;
EditorApplication.SaveScene();
Debug.Log("Saving Scene ...");
}
}
else
{
saved = false;
}
}
}
This code saves each time the play button is pressed. Since my example is different from the ones Dave gave me, I would like some some comments about this code. Is fine doing it like this? Is there a better place to ask for the isPlayingOrWillChangePlaymode than the Update?