Esempio n. 1
0
 /// <summary>
 /// starts the event system
 /// </summary>
 protected virtual void SetupEvents()
 {
     for (int i = 0; i < Events.Count; i++)
     {
         Events[i].Receiver      = InteractableEvent.CreateReceiver(Events[i]);
         Events[i].Receiver.Host = this;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// set up only one event
 /// </summary>
 protected virtual void SetupEvents()
 {
     if (Events.Count > 0)
     {
         Events[0].Receiver      = InteractableEvent.CreateReceiver(Events[0]);
         Events[0].Receiver.Host = this;
     }
 }
Esempio n. 3
0
 /// <summary>
 /// set up only one event
 /// </summary>
 protected virtual void SetupEvents()
 {
     if (Events.Count > 0)
     {
         InteractableTypesContainer interactableTypes = InteractableEvent.GetEventTypes();
         Events[0].Receiver      = InteractableEvent.GetReceiver(Events[0], interactableTypes);
         Events[0].Receiver.Host = this;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Creates the event receiver instances from the Events list
        /// </summary>
        protected virtual void SetupEvents()
        {
            InteractableTypesContainer interactableTypes = InteractableEvent.GetEventTypes();

            for (int i = 0; i < Events.Count; i++)
            {
                Events[i].Receiver      = InteractableEvent.GetReceiver(Events[i], interactableTypes);
                Events[i].Receiver.Host = this;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Event receivers can be used to listen for different
        /// events at runtime. This method allows receivers to be dynamically added at runtime.
        /// </summary>
        /// <returns>The new event receiver</returns>
        public T AddReceiver <T>() where T : ReceiverBase, new()
        {
            var interactableEvent = new InteractableEvent();
            var result            = new T();

            result.Event = interactableEvent.Event;
            interactableEvent.Receiver = result;
            Events.Add(interactableEvent);
            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// Create the event and setup the values from the inspector
        /// </summary>
        public static ReceiverBase GetReceiver(InteractableEvent iEvent, InteractableTypesContainer interactableTypes)
        {
#if UNITY_EDITOR
            int  index     = InspectorField.ReverseLookup(iEvent.ClassName, interactableTypes.ClassNames);
            Type eventType = interactableTypes.Types[index];
#else
            Type eventType = Type.GetType(iEvent.AssemblyQualifiedName);
#endif
            // apply the settings?
            ReceiverBase newEvent = (ReceiverBase)Activator.CreateInstance(eventType, iEvent.Event);
            InspectorGenericFields <ReceiverBase> .LoadSettings(newEvent, iEvent.Settings);

            return(newEvent);
        }
Esempio n. 7
0
        /// <summary>
        /// Create the event and setup the values from the inspector
        /// </summary>
        public static ReceiverBase CreateReceiver(InteractableEvent iEvent)
        {
            // Temporary workaround
            // This is to fix a bug in GA where the AssemblyQualifiedName was never actually saved. Functionality would work in editor...but never on device player
            if (iEvent.ReceiverType == null)
            {
                var correctType = TypeCacheUtility.GetSubClasses <ReceiverBase>().Where(s => s?.Name == iEvent.ClassName).First();
                iEvent.ReceiverType = correctType;
            }

            ReceiverBase newEvent = (ReceiverBase)Activator.CreateInstance(iEvent.ReceiverType, iEvent.Event);

            InspectorGenericFields <ReceiverBase> .LoadSettings(newEvent, iEvent.Settings);

            return(newEvent);
        }
 protected void SetupEventOptions()
 {
     eventOptions = InteractableEvent.GetEventTypes();
 }