UI 이벤트 추가
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UI_Base : MonoBehaviour
|
||||
@@ -59,4 +60,21 @@ public class UI_Base : MonoBehaviour
|
||||
{
|
||||
return Get<Image>(idx);
|
||||
}
|
||||
|
||||
public static void AddUIEvent(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user