Last active
November 17, 2016 14:20
-
-
Save mrcarriere/034ffde5ac162d11d997e7eebb2471de to your computer and use it in GitHub Desktop.
Automatically save dirty scenes and assets as soon as you enter playmode.
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 UnityEngine; | |
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
[InitializeOnLoad] | |
public class SaveSceneOnPlay | |
{ | |
static SaveSceneOnPlay() | |
{ | |
EditorApplication.playmodeStateChanged += () => | |
{ | |
if (!EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode) | |
{ | |
Debug.Log("Autosaving dirty scenes and assets."); | |
EditorSceneManager.SaveOpenScenes(); | |
AssetDatabase.SaveAssets(); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment