Beispiel #1
0
    public static void AddUIHandler(GameObject go, Action <PointerEventData> action, Defines.UIEvent type = Defines.UIEvent.Click)
    {
        UI_EventHandler evt = Utils.GetOrAddComponent <UI_EventHandler>(go);

        switch (type)
        {
        case Defines.UIEvent.Click:
            evt.OnClickHandler -= action;
            evt.OnClickHandler += action;
            break;
        }
    }
 void Singleton()
 {
     if (_instance == null)
     {
         GameObject _MgrOb = GameObject.Find("@EventSystem");
         if (_MgrOb == null)
         {
             _MgrOb = new GameObject {
                 name = "@EventSystem"
             };
             _MgrOb.AddComponent <Managers>();
         }
         _instance = _MgrOb.GetComponent <UI_EventHandler>();
         DontDestroyOnLoad(_MgrOb);
     }
 }
Beispiel #3
0
    public static void BindEvent(GameObject go, Action <PointerEventData> action, Define.UIEvent type = Define.UIEvent.Click)
    {
        UI_EventHandler evt = Util.GetOrAddComponent <UI_EventHandler>(go);

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

        case Define.UIEvent.Drag:
            evt.OnDragHandler -= action;
            evt.OnDragHandler += action;
            break;
        }
    }
Beispiel #4
0
    //게임 오브젝트, 액션, 이벤트 정의(Define)
    public static void BindEvent(GameObject go, Action <PointerEventData> action, Define.UIEvent type = Define.UIEvent.Click)  //Define 초기값으로는 가장 많이 쓰는 click 이벤트루 지정
    {
        UI_EventHandler evt = Util.GetOrAddComponent <UI_EventHandler>(go);

        switch (type)
        {
        case Define.UIEvent.Click:
            evt.OnClickHandler -= action;     //이전에 있던 액션이 걸려있는경우를 대비해 한번 뺘줌
            evt.OnClickHandler += action;
            break;

        case Define.UIEvent.Drag:
            evt.OnDragHandler -= action;
            evt.OnDragHandler += action;
            break;
        }
        //evt.OnDragHandler += ((PointerEventData data)=>{evt.gameObject.transform.position = data.position;});
    }
Beispiel #5
0
    public static void BindEvent(GameObject go, Action <PointerEventData> action, Define.UIEvent type = Define.UIEvent.Click)
    {
        UI_EventHandler evt = Util.GetOrAddComponent <UI_EventHandler>(go);

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

        case Define.UIEvent.Drag:
            evt.OnDragHandler -= action;
            evt.OnDragHandler += action;
            break;
        }
        evt.OnDragHandler += ((PointerEventData data) => { evt.gameObject.transform.position = data.position; });
    }
Beispiel #6
0
    // Start is called before the first frame update


    //UI 게임오브젝트에 이벤트를 추가해주는 함수
    public static void BindEvent(GameObject go, Action <PointerEventData> action, Define.UIEvent type = Define.UIEvent.Click)
    {
        //go라는 오브젝트에 UI_EventHandler 스크립트를 넣어준다 (게임에 들어가기에 생성됨. )
        UI_EventHandler evt = Util.GetOrAddComponent <UI_EventHandler>(go);

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

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

        case Define.UIEvent.DragBegin:
            evt.OnBeginDragHandler -= action;
            evt.OnBeginDragHandler += action;
            break;

        case Define.UIEvent.DragEnd:
            evt.OnEndDragHandler -= action;
            evt.OnEndDragHandler += action;
            break;

        case Define.UIEvent.ClickDown:
            evt.OnPointerDownHandler -= action;
            evt.OnPointerDownHandler += action;
            break;

        case Define.UIEvent.MoushEnter:
            evt.OnPointerEnterHandler -= action;
            evt.OnPointerEnterHandler += action;
            break;

        case Define.UIEvent.MoushExit:
            evt.OnPointerExitHandler -= action;
            evt.OnPointerExitHandler += action;
            break;
        }
    }
Beispiel #7
0
    public static void BindUIEvent(GameObject go, Action <PointerEventData> action, Define.UIEvent type)
    {
        UI_EventHandler evt = Util.GetOrAddComponent <UI_EventHandler>(go);

        switch (type)
        {
        case Define.UIEvent.OnPointerDown:
            evt.OnPointerDownAction -= action;
            evt.OnPointerDownAction += action;
            break;

        case Define.UIEvent.OnPointerUp:
            evt.OnPointerUpAction -= action;
            evt.OnPointerUpAction += action;
            break;

        case Define.UIEvent.OnPointerClick:
            evt.OnPointerClickAction -= action;
            evt.OnPointerClickAction += action;
            break;

        case Define.UIEvent.OnBeginDrag:
            evt.OnBeginDragAction -= action;
            evt.OnBeginDragAction += action;
            break;

        case Define.UIEvent.OnDrag:
            evt.OnDragAction -= action;
            evt.OnDragAction += action;
            break;

        case Define.UIEvent.OnEndDrag:
            evt.OnEndDragAction -= action;
            evt.OnEndDragAction += action;
            break;

        case Define.UIEvent.OnDrop:
            evt.OnDropAction -= action;
            evt.OnDropAction += action;
            break;
        }
    }
    public static void BindEvent(GameObject go, Action <PointerEventData> _call, Define.UIEvent type = Define.UIEvent.Click)
    {
        UI_EventHandler handle = Util.GetOrAddComponent <UI_EventHandler>(go);

        switch (type)
        {
        case Define.UIEvent.Click:
        {
            handle.OnPointerClickHandler -= _call;
            handle.OnPointerClickHandler += _call;
        }
        break;

        case Define.UIEvent.Drag:
        {
            handle.OnDragHandler -= _call;
            handle.OnDragHandler += _call;
        }
        break;
        }
    }
Beispiel #9
0
    static public void AddUIEvent(GameObject gameObject, System.Action <PointerEventData> action, E_UIEVENT type)
    {
        UI_EventHandler ev = Common.GetOrAddComponent <UI_EventHandler>(gameObject);

        if (ev == null)
        {
            return;
        }

        switch (type)
        {
        case E_UIEVENT.CLICK:
            ev.ClickAction = action;
            break;

        case E_UIEVENT.DOWN:
            ev.DownAction = action;
            break;

        case E_UIEVENT.UP:
            ev.UpAction = action;
            break;

        case E_UIEVENT.BEGIN_DRAG:
            ev.BeginDragAction = action;
            break;

        case E_UIEVENT.DRAG:
            ev.OnDragAction = action;
            break;

        case E_UIEVENT.EXIT_DRAG:
            ev.ExitDragAction = action;
            break;
        }
    }