Example #1
0
 /// <summary>
 /// Adds the click.
 /// </summary>
 /// <param name="go">GameObject.</param>
 /// <param name="callback">Callback.</param>
 public static void AddClick(GameObject go, Action <XLAF_UIEvent> onUIEvent)
 {
     XLAFEventTriggerListener.Get(go).onClick = (GameObject g, PointerEventData e) => {
         XLAF_UIEvent evt = new XLAF_UIEvent();
         evt.eventData = e;
         evt.target    = g;
         evt.phase     = Phase.Click;
         onUIEvent(evt);
     };
 }
Example #2
0
 /// <summary>
 /// Adds the touch event.
 /// </summary>
 /// <param name="go">GameObject.</param>
 /// <param name="onUIEvent">On user interface event.</param>
 public static void AddTouchEvent(GameObject go, Action <XLAF_UIEvent> onUIEvent)
 {
     XLAFEventTriggerListener.Get(go).onBeginDrag = (GameObject g, PointerEventData e) => {
         XLAF_UIEvent evt = new XLAF_UIEvent();
         evt.eventData = e;
         evt.target    = g;
         evt.phase     = Phase.BeginDrag;
         onUIEvent(evt);
     };
     XLAFEventTriggerListener.Get(go).onDrag = (GameObject g, PointerEventData e) => {
         XLAF_UIEvent evt = new XLAF_UIEvent();
         evt.eventData = e;
         evt.target    = g;
         evt.phase     = Phase.Dragging;
         onUIEvent(evt);
     };
     XLAFEventTriggerListener.Get(go).onEndDrag = (GameObject g, PointerEventData e) => {
         XLAF_UIEvent evt = new XLAF_UIEvent();
         evt.eventData = e;
         evt.target    = g;
         evt.phase     = Phase.EndDrag;
         onUIEvent(evt);
     };
     XLAFEventTriggerListener.Get(go).onDown = (GameObject g, PointerEventData e) => {
         XLAF_UIEvent evt = new XLAF_UIEvent();
         evt.eventData = e;
         evt.target    = g;
         evt.phase     = Phase.Down;
         onUIEvent(evt);
     };
     XLAFEventTriggerListener.Get(go).onUp = (GameObject g, PointerEventData e) => {
         XLAF_UIEvent evt = new XLAF_UIEvent();
         evt.eventData = e;
         evt.target    = g;
         evt.phase     = Phase.Up;
         onUIEvent(evt);
     };
     XLAFEventTriggerListener.Get(go).onEnter = (GameObject g, PointerEventData e) => {
         XLAF_UIEvent evt = new XLAF_UIEvent();
         evt.eventData = e;
         evt.target    = g;
         evt.phase     = Phase.Enter;
         onUIEvent(evt);
     };
     XLAFEventTriggerListener.Get(go).onExit = (GameObject g, PointerEventData e) => {
         XLAF_UIEvent evt = new XLAF_UIEvent();
         evt.eventData = e;
         evt.target    = g;
         evt.phase     = Phase.Exit;
         onUIEvent(evt);
     };
 }
Example #3
0
        /// <summary>
        /// Adds the click.
        /// </summary>
        /// <param name="go">Go.</param>
        /// <param name="preventDoubleClickTime">Prevent double click time (second).</param>
        /// <param name="onUIEvent">On user interface event.</param>
        public static void AddClick(GameObject go, float preventDoubleClickTime, Action <XLAF_UIEvent> onUIEvent)
        {
            bool isDelaying = false;

            XLAFEventTriggerListener.Get(go).onClick = (GameObject g, PointerEventData e) => {
                if (isDelaying)
                {
                    XLAFInnerLog.Warning(string.Format("You pressed {0} in {1} second(s), will not response.", g.name, preventDoubleClickTime));
                    return;
                }
                isDelaying = true;
                ModUtils.DelayCall(preventDoubleClickTime, () => {
                    isDelaying = false;
                });
                XLAF_UIEvent evt = new XLAF_UIEvent();
                evt.eventData = e;
                evt.target    = g;
                evt.phase     = Phase.Click;
                onUIEvent(evt);
            };
        }
Example #4
0
 /// <summary>
 /// user interface event.
 /// </summary>
 /// <param name="e">Event.</param>
 public virtual void OnUIEvent(XLAF_UIEvent e)
 {
 }