Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class ResettableScriptableObject : ScriptableObject
- {
- #if UNITY_EDITOR
- [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
- private static void CallBeforPlayScene()
- {
- UnityEditor.AssetDatabase.SaveAssets ();
- }
- #endif
- protected virtual void OnEnable()
- {
- #if UNITY_EDITOR
- if( UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode == true ){
- UnityEditor.EditorApplication.playmodeStateChanged += () => {
- if( UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode == false) {
- Resources.UnloadAsset(this);
- }
- };
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement