Exemple #1
0
        public void Awake()
        {
            dynamicEventList = new List <DynamicDelegate>();

            // Go through every event and hook into the given reactions
            if (eventSender != null)
            {
                foreach (string key in reactionsPerEventDictionary.Keys)
                {
                    for (int n = 0; n < reactionsPerEventDictionary[key].reactionList.Count; n++)
                    {
                        // Skip any null reactions
                        if (reactionsPerEventDictionary[key].reactionList[n] != null)
                        {
                            dynamicEventList.Add(EventUtility.SubscribeToEvent(reactionsPerEventDictionary[key].reactionList[n],
                                                                               eventSender,
                                                                               key,
                                                                               reactionsPerEventDictionary[key].reactionTriggerMethodList[n],
                                                                               eventSender.GetType(),
                                                                               reactionsPerEventDictionary[key].reactionList[n].GetType(),
                                                                               BindingFlags.Instance | BindingFlags.Public));
                        }
                    }
                }
            }
        }
        protected void OnEnable()
        {
            for (int n = 0; n < dependencyList.Count; n++)
            {
                if (dependencyList[n].providedEvent is TimelineEvent)
                {
                    TimelineEvent currentEvent = dependencyList[n].providedEvent as TimelineEvent;

                    awaitingEvents.Add(currentEvent);

                    dynamicDelegateList.Add(EventUtility.SubscribeToEvent(this,
                                                                          currentEvent,
                                                                          dependencyList[n].eventToListen,
                                                                          "OnDependentTimeline",
                                                                          null,
                                                                          GetType(),
                                                                          BindingFlags.Instance | BindingFlags.NonPublic));
                }
                else if (dependencyList[n].providedEvent is InteractionArea)
                {
                    InteractionArea currentEvent = dependencyList[n].providedEvent as InteractionArea;

                    awaitingEvents.Add(currentEvent);

                    dynamicDelegateList.Add(EventUtility.SubscribeToEvent(this,
                                                                          currentEvent,
                                                                          dependencyList[n].eventToListen,
                                                                          "OnDependentInteractionArea",
                                                                          null,
                                                                          GetType(),
                                                                          BindingFlags.Instance | BindingFlags.NonPublic));
                }
                else if (dependencyList[n].providedEvent is GestureInteraction)
                {
                    GestureInteraction currentEvent = dependencyList[n].providedEvent as GestureInteraction;

                    awaitingEvents.Add(currentEvent);

                    dynamicDelegateList.Add(EventUtility.SubscribeToEvent(this,
                                                                          currentEvent,
                                                                          dependencyList[n].eventToListen,
                                                                          "OnDependentTimeline",
                                                                          null,
                                                                          GetType(),
                                                                          BindingFlags.Instance | BindingFlags.NonPublic));
                }
            }

            // If there are no dependencies, you start at the scene's start
            CheckDependencyCount();
        }