コード例 #1
0
        /// <summary>
        /// Processes a single event listener phases
        /// </summary>
        /// <param name="adapter">Component descriptor referencing event handlers</param>
        /// <param name="component">Component dispatching events</param>
        /// <param name="mapping">Event mapping</param>
        /// <param name="enabled">Enabled state</param>
        public static void ProcessPhases(ComponentAdapter adapter, Components.Component component, EventMapping mapping, bool enabled)
        {
            if (null == component && null == adapter.Component)  // not instantiated (edit mode) and no component supplied
            {
                return;
            }

            Component script = adapter.GetComponent(mapping.ScriptName);

            if (null == script)
            {
                Debug.LogWarning("Component " + mapping.ScriptName + " not found on " + adapter.gameObject);
                return;
            }

            Type         type       = script.GetType();
            MethodInfo   methodInfo = type.GetMethod(mapping.MethodName, AllInstanceMethodsBindingFlags, null, TypeOfEvent, Modifiers); //type.GetMethod(mapping.MethodName, TypeOfEvent);
            EventHandler handler    = (EventHandler)Delegate.CreateDelegate(typeof(EventHandler), script, methodInfo);

            var cmp = component ?? adapter.Component;

            /**
             * 1. Remove all phases
             * */
            cmp.RemoveEventListener(mapping.EventType, handler, EventPhase.Capture | EventPhase.Target | EventPhase.Bubbling);

            /**
             * 2. If enabled, subscribe again
             * */
            if (enabled)
            {
                cmp.AddEventListener(mapping.EventType, handler, mapping.Phase);
            }
        }
コード例 #2
0
        public override void AddEventListener(string eventType, EventHandler handler, EventPhase phases)
        {
            base.AddEventListener(eventType, handler, phases);

            _touchCount++;
            SystemManager.Instance.TouchSignal.Connect(TouchSlot);
        }
コード例 #3
0
        public override void RemoveEventListener(string eventType, EventHandler handler, EventPhase phases)
        {
            base.RemoveEventListener(eventType, handler, phases);

            _touchCount--;
            if (_touchCount <= 0)
            {
                SystemManager.Instance.TouchSignal.Disconnect(TouchSlot);
            }
        }
コード例 #4
0
 /// <summary>
 /// Overriding the MAIN RemoveEventListener method!
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="handler"></param>
 /// <param name="phases"></param>
 public override void RemoveEventListener(string eventType, EventHandler handler, EventPhase phases)
 {
     if (eventType == "propertyChange")
     {
         if (!HasEventListener(eventType))
         {
             TileLayout.RemoveEventListener(eventType, RedispatchHandler);
         }
     }
     base.RemoveEventListener(eventType, handler, phases);
 }
コード例 #5
0
 /// <summary>
 /// Overriding the MAIN AddEventListener method!
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="handler"></param>
 /// <param name="phases"></param>
 /// <param name="priority"></param>
 public override void AddEventListener(string eventType, EventHandler handler, EventPhase phases, int priority)
 {
     if (eventType == "propertyChange")
     {
         if (!HasEventListener(eventType))
         {
             TileLayout.AddEventListener(eventType, RedispatchHandler, phases, priority);
         }
     }
     base.AddEventListener(eventType, handler);
 }
コード例 #6
0
ファイル: Component.cs プロジェクト: onamoni/edriven-gui
        public override void RemoveEventListener(string eventType, EventHandler handler, EventPhase phases)
        {
            if (MouseEvent.ROLL_OVER == eventType)
            {
                MouseEventDispatcher.Instance.UnregisterRollOverComponent(this);
            }
            else if (MouseEvent.ROLL_OUT == eventType)
            {
                MouseEventDispatcher.Instance.UnregisterRollOverComponent(this);
            }

            base.RemoveEventListener(eventType, handler, phases);
        }
コード例 #7
0
        /// <summary>
        /// Processes a single event listener
        /// </summary>
        /// <param name="adapter">Component descriptor referencing event handlers</param>
        /// <param name="component">Component dispatching events</param>
        /// <param name="mapping">Event mapping</param>
        /// <param name="enabled">Enabled state</param>
        public static void ProcessListener(ComponentAdapter adapter, Components.Component component, EventMapping mapping, bool enabled)
        {
            if (null == component && (null == adapter || null == adapter.Component)) // not instantiated (edit mode) and no component supplied
            {
                return;                                                              // "null == adapter" check added 20130218 because having problems with prefabs
            }
            //Debug.Log("mapping.ScriptName: " + mapping.ScriptName);
            //Debug.Log("mapping: " + mapping);
            Component script = adapter.GetComponent(mapping.ScriptName);

            if (null == script)
            {
                Debug.LogWarning("Script " + mapping.ScriptName + " not found on " + adapter.gameObject, adapter.gameObject);
                return;
            }

            Type type = script.GetType();
            //Debug.Log("script: " + type);
            //Debug.Log("mapping.MethodName: " + mapping.MethodName);
            MethodInfo methodInfo = type.GetMethod(mapping.MethodName, AllInstanceMethodsBindingFlags, null, TypeOfEvent, Modifiers); //type.GetMethod(mapping.MethodName, TypeOfEvent);

            if (null == methodInfo)
            {
                Debug.LogWarning(string.Format("Method [{0}] not found in script [{1}]", mapping.MethodName, mapping.ScriptName), adapter);
                return;
            }

            //Debug.Log("method: " + methodInfo);
            EventHandler handler = (EventHandler)Delegate.CreateDelegate(typeof(EventHandler), script, methodInfo);
            //Debug.Log("handler: " + handler);

            var cmp = component ?? adapter.Component;

            if (enabled)
            {
                //Debug.Log("Wiring [" + mapping.EventType + "] event to [" + handler + "] handler on " + componentDescriptor);
                cmp.AddEventListener(mapping.EventType, handler, mapping.Phase);
            }
            else
            {
                cmp.RemoveEventListener(mapping.EventType, handler, mapping.Phase);
            }
        }
コード例 #8
0
        public override void RemoveEventListener(string eventType, EventHandler handler, EventPhase phases)
        {
            base.RemoveEventListener(eventType, handler, phases);

            _touchCount--;
            if (_touchCount <= 0)
            {
                SystemManager.Instance.TouchSignal.Disconnect(TouchSlot);
            }
        }
コード例 #9
0
ファイル: Gui.cs プロジェクト: groov0v/edriven-gui
 /// <summary>
 /// Removes an event listener
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="handler"></param>
 /// <param name="phases"></param>
 public void RemoveEventListener(string eventType, EventHandler handler, EventPhase phases)
 {
     Stage.RemoveEventListener(eventType, handler, phases);
 }
コード例 #10
0
ファイル: Gui.cs プロジェクト: groov0v/edriven-gui
 /// <summary>
 /// Removes an event listener
 /// </summary>
 /// <param name="eventType">Event type</param>
 /// <param name="handler">Event handler (function)</param>
 public void RemoveEventListener(string eventType, EventHandler handler)
 {
     Stage.RemoveEventListener(eventType, handler);
 }
コード例 #11
0
ファイル: Gui.cs プロジェクト: groov0v/edriven-gui
 /// <summary>
 /// Adds the event listener
 /// </summary>
 /// <param name="eventType">Event type</param>
 /// <param name="handler">Event handler</param>
 /// <param name="phases">Event bubbling phases that we listen to</param>
 /// <param name="priority">Event priority</param>
 public void AddEventListener(string eventType, EventHandler handler, EventPhase phases, int priority)
 {
     Stage.AddEventListener(eventType, handler, phases, priority);
 }
コード例 #12
0
ファイル: Gui.cs プロジェクト: groov0v/edriven-gui
 /// <summary>
 /// Adds event listener
 /// </summary>
 /// <param name="eventType">Event type</param>
 /// <param name="handler">Event handler (function)</param>
 public void AddEventListener(string eventType, EventHandler handler)
 {
     Stage.AddEventListener(eventType, handler);
 }
コード例 #13
0
ファイル: Gui.cs プロジェクト: onamoni/edriven-gui
 /// <summary>
 /// Removes an event listener
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="handler"></param>
 /// <param name="phases"></param>
 public void RemoveEventListener(string eventType, EventHandler handler, EventPhase phases)
 {
     Stage.RemoveEventListener(eventType, handler, phases);
 }
コード例 #14
0
ファイル: Gui.cs プロジェクト: onamoni/edriven-gui
 /// <summary>
 /// Removes an event listener
 /// </summary>
 /// <param name="eventType">Event type</param>
 /// <param name="handler">Event handler (function)</param>
 public void RemoveEventListener(string eventType, EventHandler handler)
 {
     Stage.RemoveEventListener(eventType, handler);
 }
コード例 #15
0
ファイル: Gui.cs プロジェクト: onamoni/edriven-gui
 /// <summary>
 /// Adds the event listener
 /// </summary>
 /// <param name="eventType">Event type</param>
 /// <param name="handler">Event handler</param>
 /// <param name="phases">Event bubbling phases that we listen to</param>
 /// <param name="priority">Event priority</param>
 public void AddEventListener(string eventType, EventHandler handler, EventPhase phases, int priority)
 {
     Stage.AddEventListener(eventType, handler, phases, priority);
 }
コード例 #16
0
ファイル: TileGroup.cs プロジェクト: groov0v/edriven-gui
 /// <summary>
 /// Overriding the MAIN RemoveEventListener method!
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="handler"></param>
 /// <param name="phases"></param>
 public override void RemoveEventListener(string eventType, EventHandler handler, EventPhase phases)
 {
     if (eventType == "propertyChange")
     {
         if (!HasEventListener(eventType))
             TileLayout.RemoveEventListener(eventType, RedispatchHandler);
     }
     base.RemoveEventListener(eventType, handler, phases);
 }
コード例 #17
0
 public override void RemoveEventListener(string eventType, EventHandler handler)
 {
     // listening for Target and Bubbling phases by default
     base.RemoveEventListener(eventType, handler, EventPhase.Target | EventPhase.Bubbling);
 }
コード例 #18
0
        public override void AddEventListener(string eventType, EventHandler handler, EventPhase phases)
        {
            base.AddEventListener(eventType, handler, phases);

            _touchCount++;
            SystemManager.Instance.TouchSignal.Connect(TouchSlot);
        }
コード例 #19
0
 public override void RemoveEventListener(string eventType, EventHandler handler)
 {
     // listening for Target and Bubbling phases by default
     base.RemoveEventListener(eventType, handler, EventPhase.Target | EventPhase.Bubbling);
 }
コード例 #20
0
ファイル: Component.cs プロジェクト: groov0v/edriven-gui
 public override void RemoveEventListener(string eventType, EventHandler handler, EventPhase phases)
 {
     if (MouseEvent.ROLL_OVER == eventType)
     {
         MouseEventDispatcher.Instance.UnregisterRollOverComponent(this);
     }
     else if (MouseEvent.ROLL_OUT == eventType)
     {
         MouseEventDispatcher.Instance.UnregisterRollOverComponent(this);
     }
     
     base.RemoveEventListener(eventType, handler, phases);
 }
コード例 #21
0
ファイル: Gui.cs プロジェクト: onamoni/edriven-gui
 /// <summary>
 /// Adds event listener
 /// </summary>
 /// <param name="eventType">Event type</param>
 /// <param name="handler">Event handler (function)</param>
 public void AddEventListener(string eventType, EventHandler handler)
 {
     Stage.AddEventListener(eventType, handler);
 }
コード例 #22
0
ファイル: TileGroup.cs プロジェクト: groov0v/edriven-gui
 /// <summary>
 /// Overriding the MAIN AddEventListener method!
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="handler"></param>
 /// <param name="phases"></param>
 /// <param name="priority"></param>
 public override void AddEventListener(string eventType, EventHandler handler, EventPhase phases, int priority)
 {
     if (eventType == "propertyChange")
     {
         if (!HasEventListener(eventType))
             TileLayout.AddEventListener(eventType, RedispatchHandler, phases, priority);
     }
     base.AddEventListener(eventType, handler);
 }