Пример #1
0
    public static void BindEvent(GameObject obj, Action <PointerEventData> action, Define.UiEvent type = Define.UiEvent.Click)
    {
        UiEventHandler eventHandler = Util.GetOrAddComponent <UiEventHandler>(obj);

        switch (type)
        {
        case Define.UiEvent.Click:
            if (action != null)
            {
                eventHandler.OnClickHandler -= action;
                eventHandler.OnClickHandler += action;
            }

            break;

        case Define.UiEvent.Drag:
            if (action != null)
            {
                eventHandler.OnDragHandler -= action;
                eventHandler.OnDragHandler += action;
            }

            break;
        }
    }
Пример #2
0
    public static GameObject BindEvent(GameObject go, Action <PointerEventData> action, Define.UiEvent type = Define.UiEvent.Click)
    {
        UiEventHandler evt = go.GetOrAddComponent <UiEventHandler>();

        switch (type)
        {
        case Define.UiEvent.Click:
            evt.OnClickHandler -= action;
            evt.OnClickHandler += action;
            break;

        case Define.UiEvent.Drag:
            evt.OnDragHandler -= action;
            evt.OnDragHandler += action;
            break;

        default:
            break;
        }

        return(go);
    }
Пример #3
0
 public static GameObject BindEvent(this GameObject go, Action <PointerEventData> action, Define.UiEvent type = Define.UiEvent.Click)
 {
     return(CustomUtility.BindEvent(go, action, type));
 }
Пример #4
0
 public static void BindEvent(this GameObject obj, Action <PointerEventData> action,
                              Define.UiEvent type = Define.UiEvent.Click)
 {
     UiBase.BindEvent(obj, action, type);
 }