using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIAutoClose : MonoBehaviour { // Start is called before the first frame update void Start() { StartCoroutine(AutoClose()); } IEnumerator AutoClose() { yield return 0; yield return new WaitForSeconds(2.5f); if(gameObject) gameObject.SetActive(false); } }