public static void RemoveOnClick(this UIPointerClick self) { if (self.__onclick != null) { self.unity_pointerclick.onClick.RemoveListener(self.__onclick); } self.__onclick = null; }
public static void SetOnClick(this UIPointerClick self, UnityAction callback) { self.ActivatingComponent(); self.RemoveOnClick(); self.__onclick = () => { //AkSoundEngine.PostEvent("ConFirmation", Camera.main.gameObject); callback(); }; self.unity_pointerclick.onClick.AddListener(self.__onclick); }
static void ActivatingComponent(this UIPointerClick self) { if (self.unity_pointerclick == null) { self.unity_pointerclick = self.GetGameObject().GetComponent <PointerClick>(); if (self.unity_pointerclick == null) { self.unity_pointerclick = self.GetGameObject().AddComponent <PointerClick>(); Log.Info($"添加UI侧组件UIPointerClick时,物体{self.GetGameObject().name}上没有找到PointerClick组件"); } } }
public static void SetEnabled(this UIPointerClick self, bool flag) { self.ActivatingComponent(); self.unity_pointerclick.enabled = flag; }
//虚拟点击 public static void Click(this UIPointerClick self) { self.__onclick?.Invoke(); }