Esempio n. 1
0
 public void AddAxisEvent(EventTriggerType triggerType, LuaTable value)
 {
     if (_eventDic.ContainsKey(triggerType))
     {
         _eventDic[triggerType].luaTables.Add(value.Get <int>("_instanceId"), value);
     }
     else
     {
         UIEventBase uIEventBase = UITool.GetUIEventBase(this._gameObject, triggerType);
         if (uIEventBase == null)
         {
             throw new Exception($"{triggerType}的事件类型没有找到!");
         }
         _eventDic.Add(triggerType, uIEventBase);
         uIEventBase.luaTables.Add(value.Get <int>("_instanceId"), value);
     }
 }
Esempio n. 2
0
        internal static UIEventBase GetUIEventBase(GameObject obj, EventTriggerType triggerType)
        {
            UIEventBase uIEventBase = null;

            switch (triggerType)
            {
            case EventTriggerType.PointerEnter:
                uIEventBase = obj.AddComponent <UIPointerEnterEvent>();
                break;

            case EventTriggerType.PointerExit:
                uIEventBase = obj.AddComponent <UIPointerExitEvent>();
                break;

            case EventTriggerType.PointerDown:
                uIEventBase = obj.AddComponent <UIPointerDownEvent>();
                break;

            case EventTriggerType.PointerUp:
                uIEventBase = obj.AddComponent <UIPointerUpEvent>();
                break;

            case EventTriggerType.PointerClick:
                uIEventBase = obj.AddComponent <UIPointerClickEvent>();
                break;

            case EventTriggerType.Drag:
                uIEventBase = obj.AddComponent <UIDragEvent>();
                break;

            case EventTriggerType.BeginDrag:
                uIEventBase = obj.AddComponent <UIBeginDragEvent>();
                break;

            case EventTriggerType.EndDrag:
                uIEventBase = obj.AddComponent <UIEndDragEvent>();
                break;

            case EventTriggerType.Submit:
                uIEventBase = obj.AddComponent <UISubmitEvent>();
                break;

            case EventTriggerType.Cancel:
                uIEventBase = obj.AddComponent <UICancelEvent>();
                break;

            case EventTriggerType.Drop:
                uIEventBase = obj.AddComponent <UIDropEvent>();
                break;

            case EventTriggerType.Scroll:
                uIEventBase = obj.AddComponent <UIScrollEvent>();
                break;

            case EventTriggerType.UpdateSelected:
                uIEventBase = obj.AddComponent <UIUpdateSelectedEvent>();
                break;

            case EventTriggerType.Select:
                uIEventBase = obj.AddComponent <UISelectEvent>();
                break;

            case EventTriggerType.Deselect:
                uIEventBase = obj.AddComponent <UIDeselectEvent>();
                break;

            case EventTriggerType.Move:
                uIEventBase = obj.AddComponent <UIMoveEvent>();
                break;

            case EventTriggerType.InitializePotentialDrag:
                uIEventBase = obj.AddComponent <UIInitializePotentialDragEvent>();
                break;
            }
            return(uIEventBase);
        }