Пример #1
0
 /// <summary>
 /// 移除UI控件的所有监听器
 /// </summary>
 /// <param name="target"></param>
 public void RemoveUIClickListeners(UIBehaviour target)
 {
     if (target != null)
     {
         if (UIEventTrigger.HasExistOn(target.transform))
         {
             UIEventTrigger.Get(target).onClick = null;
         }
     }
 }
Пример #2
0
    /// <summary>
    /// 移除UI控件的监听器
    /// </summary>
    /// <param name="controlName"></param>
    /// <param name="listener"></param>
    public void RemoveUIClickListener(string controlName, Action <string> listener)
    {
        Transform target = transform.Find(controlName);

        if (target != null)
        {
            if (UIEventTrigger.HasExistOn(target))
            {
                UIEventTrigger.Get(target).onClickWithName -= listener;
            }
        }
        else
        {
            Debug.LogError("未找到UI控件:" + controlName);
        }
    }