I use Visual Studio a lot and one of the things I came to rely on is the project saving everytime I run it.
I wanted the same for Unity scenes so I created a simple little script.
To use it:
-
Add the script to your scene.
-
Go to Edit–>Project Settings–>Script Execution Order and set your “SaveOnPlay” script to execute first. (This is so it saves before any of your code runs that may modify the scene programmatically.)
Note: You’ll want to remove/disable this script prior to releasing you game.
That’s it. Let me know what you think.
The script:
using UnityEngine;
using UnityEditor;
using System.Collections;
public class SaveOnPlay : MonoBehaviour {
void Awake()
{
EditorApplication.playmodeStateChanged += HandlePlayModeStateChanged;
}
void HandlePlayModeStateChanged()
{
EditorApplication.SaveScene();
EditorApplication.playmodeStateChanged -= HandlePlayModeStateChanged; //don't fire event on exiting play
}
}