Пример #1
0
 /// <summary>
 /// Removes the touch event.
 /// </summary>
 /// <param name="go">GameObject.</param>
 public static void RemoveTouchEvent(GameObject go)
 {
     XLAFEventTriggerListener.Get(go).onBeginDrag = null;
     XLAFEventTriggerListener.Get(go).onDrag      = null;
     XLAFEventTriggerListener.Get(go).onEndDrag   = null;
     XLAFEventTriggerListener.Get(go).onDown      = null;
     XLAFEventTriggerListener.Get(go).onUp        = null;
     XLAFEventTriggerListener.Get(go).onEnter     = null;
     XLAFEventTriggerListener.Get(go).onExit      = null;
 }
Пример #2
0
        public static XLAFEventTriggerListener Get(GameObject go)
        {
            XLAFEventTriggerListener listener = go.GetComponent <XLAFEventTriggerListener> ();

            if (listener == null)
            {
                listener = go.AddComponent <XLAFEventTriggerListener> ();
            }
            return(listener);
        }
Пример #3
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);
     };
 }
Пример #4
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);
     };
 }
Пример #5
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);
            };
        }
Пример #6
0
 /// <summary>
 /// Sets the backdoor.
 /// Callback<isHandled,cmdString>
 /// </summary>
 /// <param name="transform">Transform.</param>
 /// <param name="callback">Callback<isHandled,cmd>.</param>
 public static void SetBackdoor(GameObject gameObject, Action <bool, string> callback)
 {
     XLAFEventTriggerListener.Get(gameObject).onClick = OnClick;
     MgrBackdoor.callback = callback;
 }
Пример #7
0
 /// <summary>
 /// Removes the click.
 /// </summary>
 /// <param name="go">GameObject.</param>
 public static void RemoveClick(GameObject go)
 {
     XLAFEventTriggerListener.Get(go).onClick = null;
 }