using AX.MessageSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class HideUIWhileClear : MonoBehaviour { // Use this for initialization void Start() { MessageDispatcher.AddListener("ClearObject", HideUI); } private void HideUI(IMessage obj) { if (GetComponent()) { GetComponent().Clear(); return; } if (gameObject.activeInHierarchy) { gameObject.SetActive(false); } } private void OnDestroy() { MessageDispatcher.RemoveListener("ClearObject", HideUI); } }