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; } }
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); }
public static GameObject BindEvent(this GameObject go, Action <PointerEventData> action, Define.UiEvent type = Define.UiEvent.Click) { return(CustomUtility.BindEvent(go, action, type)); }
public static void BindEvent(this GameObject obj, Action <PointerEventData> action, Define.UiEvent type = Define.UiEvent.Click) { UiBase.BindEvent(obj, action, type); }