public void AddAction <T>(string constantStrings, Action <T> action, DeleteGameObjectEnum onDestroy, bool solo = false) { PearlEventsManager.AddAction(constantStrings, action, solo); if (onDestroy == DeleteGameObjectEnum.Destroy) { DestroyHandler += () => PearlEventsManager.RemoveAction(constantStrings, action); } else if (onDestroy == DeleteGameObjectEnum.Disable) { EnableHandler += (PearlBehaviour @this) => PearlEventsManager.AddAction(constantStrings, action); DisableHandler += (PearlBehaviour @this) => PearlEventsManager.RemoveAction(constantStrings, action); } }
public void AddUnityAction(UnityEvent unityEvent, UnityAction action, DeleteGameObjectEnum onDestroy) { if (unityEvent != null && action != null) { unityEvent.AddListener(action); if (onDestroy == DeleteGameObjectEnum.Destroy) { DestroyHandler += () => unityEvent.RemoveListener(action); } else if (onDestroy == DeleteGameObjectEnum.Disable) { EnableHandler += (PearlBehaviour @this) => unityEvent.AddListener(action); DisableHandler += (PearlBehaviour @this) => unityEvent.RemoveListener(action); } } }