using System.Collections; using System.Collections.Generic; using UnityEngine; public class autoDisableGameObj : MonoBehaviour { public float disableTime = 5f; /// /// This function is called when the object becomes enabled and active. /// void OnEnable() { StartCoroutine(DisableIteself()); } private IEnumerator DisableIteself() { yield return new WaitForSeconds(disableTime); gameObject.SetActive(false); } }