Created
November 25, 2019 22:55
-
-
Save SiarheiPilat/d2b64eb633d5a0399b3c2ea6e59c21f9 to your computer and use it in GitHub Desktop.
This tiny class will Autosave your project whenever you play your scene!
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; | |
// Credit goes to Comp-3 Interactive, thanks for sharing the script! | |
// This tiny class will Autosave your project whenever you play your scene! | |
[InitializeOnLoad] | |
public class Autosave | |
{ | |
static Autosave() | |
{ | |
EditorApplication.playModeStateChanged += SaveOnPlay; | |
} | |
private static void SaveOnPlay(PlayModeStateChange state) | |
{ | |
if(state == PlayModeStateChange.ExitingEditMode) | |
{ | |
Debug.Log("Auto-saving..."); | |
EditorSceneManager.SaveOpenScenes(); | |
AssetDatabase.SaveAssets(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment