Created
August 14, 2018 20:21
-
-
Save cavey79/3aaf59cd8d2b3c1819ef6be401dcb0bd to your computer and use it in GitHub Desktop.
Unity Auto-Save On Run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
using UnityEngine.SceneManagement; | |
[InitializeOnLoad] | |
public static class AutosaveOnRun | |
{ | |
static AutosaveOnRun() | |
{ | |
EditorApplication.playModeStateChanged += LogPlayModeState; | |
} | |
private static void LogPlayModeState(PlayModeStateChange state) | |
{ | |
if (state == PlayModeStateChange.ExitingEditMode) | |
{ | |
EditorSceneManager.SaveScene(SceneManager.GetActiveScene()); | |
AssetDatabase.SaveAssets(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment