public void Initialize(List <Character> list, UnityEngine.Events.UnityAction callback) { OnChangeCallbak.RemoveAllListeners(); OnChangeCallbak.AddListener(callback); index = 0; charas = list; SetData(); }
protected virtual void OnDestroy() { if (executeWhen.Equals(ExecuteWhen.DESTROY)) { Execute(); } actionToExecute.RemoveAllListeners(); //If is not pooled object and must be executed on event i need to StopListening OnDestroy if (executeWhen.Equals(ExecuteWhen.EVENT) && !isPooledObject) { EventManager.StopListening(eventToListen, Execute); } }
public static void AddListenerOnly(this UnityEngine.Events.UnityEvent unityEvent, UnityEngine.Events.UnityAction unityAction) { unityEvent.RemoveAllListeners(); unityEvent.AddListener(unityAction); }