//其实也会有一种情况就是 不可点击,但是我不删除component,省再次注册。 #region 移除 public static void Remove(GameObject go) { GUIEventListener listener = go.GetComponent <GUIEventListener>(); if (listener != null) { Destroy(listener); } }
static public GUIEventListener Get(GameObject go) { GUIEventListener listener = go.GetComponent <GUIEventListener>(); if (listener == null) { listener = go.AddComponent <GUIEventListener>(); } return(listener); }
public static void Remove(GameObject[] gos) { for (int i = 0; i < gos.Length; i++) { GUIEventListener listener = gos[i].GetComponent <GUIEventListener>(); if (listener != null) { Destroy(listener); } } }
static public GUIEventListener Get(GameObject go, int i, int j) { GUIEventListener listener = go.GetComponent <GUIEventListener>(); if (listener == null) { listener = go.AddComponent <GUIEventListener>(); } listener.index = i; listener.indey = j; return(listener); }