Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class ResettableScriptableObject : ScriptableObject
  4. {
  5. #if UNITY_EDITOR
  6. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
  7. private static void CallBeforPlayScene()
  8. {
  9. UnityEditor.AssetDatabase.SaveAssets ();
  10. }
  11. #endif
  12.  
  13. protected virtual void OnEnable()
  14. {
  15. #if UNITY_EDITOR
  16. if( UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode == true ){
  17. UnityEditor.EditorApplication.playmodeStateChanged += () => {
  18. if( UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode == false) {
  19. Resources.UnloadAsset(this);
  20. }
  21. };
  22. }
  23. #endif
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement