/// <summary> /// Call to execute actions. /// </summary> protected void OnEvent() { if (Disable) { return; } int count = m_actions.Count; for (int i = 0; i < count; i++) { INotify notify = m_actions[i]; if (notify is Notify) { Notify n = notify as Notify; n.action(gameObject); } else if (notify is NotifyWithArg) { NotifyWithArg n = notify as NotifyWithArg; n.action(gameObject, n.arg); } } }
/// <summary> /// Add a action with a argument. /// </summary> public void AddAction(Action<GameObject, object> action, object arg) { NotifyWithArg notify = new NotifyWithArg(); notify.action = action; notify.arg = arg; m_actions.Add(notify); }
/// <summary> /// Add a action with a argument. /// </summary> public void AddAction(Action <GameObject, object> action, object arg) { NotifyWithArg notify = new NotifyWithArg(); notify.action = action; notify.arg = arg; m_actions.Add(notify); }