public void OnPointerClick(PointerEventData eventData) { if(m_IsAutoClose) { UIPanelBase panel = this.GetComponentInParent<UIPanelBase>(); if (panel != null) {//如果是panel panel.Close(); } else { UIViewBase view = this.GetComponentInParent<UIViewBase>(); if(view != null) {//如果是view GameObject.Destroy(view.gameObject); } else { GameObject.Destroy(this.gameObject); } } } }