20 lines
567 B
C#
20 lines
567 B
C#
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();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|