Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using UnityEngine;
- public static class MonobehaviourExtensions
- {
- /// <summary>
- /// Use <code>
- /// private void Start() => Initialize();
- /// private void OnEnable() => this.OnAssemblyReload(Initialize);</code>
- /// </summary>
- /// <param name="mb"></param>
- /// <param name="action"></param>
- public static void OnAssemblyReload(this MonoBehaviour mb, Action action)
- {
- #if UNITY_EDITOR
- UnityEditor.AssemblyReloadEvents.afterAssemblyReload += Handler;
- #endif
- void Handler() => action();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement