/// <summary> /// Adds the state event. /// </summary> /// <param name="stateEvent"> The state event. </param> /// <param name="executionMethod"> The execution method. </param> public void AddStateEvent(IStateEvent stateEvent, EventExecutionMethod executionMethod) { switch (executionMethod) { case EventExecutionMethod.Parallel: _parallelEvents.Enqueue(stateEvent); break; case EventExecutionMethod.Default: case EventExecutionMethod.Serial: _serializedEvents.Enqueue(stateEvent); break; default: throw new ArgumentOutOfRangeException("executionMethod"); } }
public static void SendEvent <T>(this Component root, BaseEventData eventData, ExecuteEvents.EventFunction <T> callbackFunction, EventExecutionMethod method = EventExecutionMethod.Singlecast) where T : IEventSystemHandler { if (root == null) { return; } Transform[] transforms = new Transform[0]; switch (method) { case EventExecutionMethod.Singlecast: transforms = new Transform[] { root.transform }; break; case EventExecutionMethod.BroadcastDown: transforms = root.GetComponentsInChildren <Transform>(); break; case EventExecutionMethod.BroadcastUp: transforms = root.GetComponentsInParent <Transform>(); break; case EventExecutionMethod.BroadcastAll: transforms = GameObject.FindObjectsOfType(typeof(Transform)) as Transform[]; break; default: UnityEngine.Debug.Log("Unknown EventExecutionMethod!"); break; } for (int i = 0; i < transforms.Length; i++) { var go = transforms[i].gameObject; ExecuteEvents.Execute <T>(go, eventData, callbackFunction); } }