Advertisement
Muk99

AutosaveUnity

Nov 21st, 2015
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using UnityEditor;
  2. using UnityEditor.SceneManagement;
  3. using UnityEngine;
  4.  
  5. [InitializeOnLoad]
  6. public class AutosaveUnity {
  7.     static AutosaveUnity() {
  8.         EditorApplication.playmodeStateChanged = () => {
  9.             if(EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying) {
  10.                 Debug.Log("Auto-Saving project");
  11.  
  12. #if UNITY_5_2 || UNITY_5_1 || UNITY_5_0
  13.                 EditorApplication.SaveScene();
  14. #elif UNITY_5
  15.                 EditorSceneManager.SaveOpenScenes();
  16. #endif
  17.                 EditorApplication.SaveAssets();
  18.             }
  19.         };
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement