static public MonoListener Get(GameObject go) { MonoListener listener = go.GetComponent <MonoListener>(); if (listener == null) { listener = go.AddComponent <MonoListener>(); } return(listener); }
public static void registUIEventTriggerForHoverOver(GameObject gameObject, Action <GameObject> listenerForHoverOver) { BoxCollider boxCollider = gameObject.transform.GetComponentInChildren <BoxCollider>(); if (boxCollider != null) { UIEventTrigger uIEventTrigger = boxCollider.gameObject.AddComponent <UIEventTrigger>(); MonoListener d = boxCollider.gameObject.AddComponent <MonoListener>(); d.actionInMono = listenerForHoverOver; uIEventTrigger.onHoverOver.Add(new EventDelegate(d, "function")); } }
internal static void registUIEventTriggerForMouseDown(GameObject gameObject, Action <GameObject> listenerForMouseDown) { BoxCollider boxCollider = gameObject.transform.GetComponentInChildren <BoxCollider>(); if (boxCollider != null) { UIEventTrigger uIEventTrigger = boxCollider.gameObject.AddComponent <UIEventTrigger>(); MonoListener d = boxCollider.gameObject.AddComponent <MonoListener>(); d.actionInMono = listenerForMouseDown; uIEventTrigger.onPress.Add(new EventDelegate(d, "function")); } }
public static void registClickListener(GameObject father, string name, Action <GameObject> ES_listenerForGameObject) { UIButton btn = getByName <UIButton>(father, name); if (btn != null) { MonoListener d = btn.gameObject.GetComponent <MonoListener>(); if (d == null) { d = btn.gameObject.AddComponent <MonoListener>(); } d.actionInMono = ES_listenerForGameObject; btn.onClick.Clear(); btn.onClick.Add(new EventDelegate(d, "function")); } }