Raphafrei

AutoSave

Nov 15th, 2016
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor;
  3.  
  4. [InitializeOnLoad]
  5. public class AutoSave: MonoBehaviour {
  6.     static AutoSave() {
  7.         EditorApplication.playmodeStateChanged = () =>
  8.         {
  9.             if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying) {
  10.                 Debug.Log("Auto-Saving scene before entering Play mode: " + EditorApplication.currentScene);
  11.  
  12.                 EditorApplication.SaveScene();
  13.                 EditorApplication.SaveAssets();
  14.             }
  15.         };
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment