Hi I’m not a coder so please be gentle…
I found this code snippet on here and its does what I need, i.e enables a game object after a given time.
What I’d like to add is the ability to set the time via a field in the inspector that way I can attach it to several objects in my scene and have different timings for each.
Any help is appreciated.
using UnityEngine;
using System.Collections;
public class DelayedSetActive : MonoBehaviour
{
void Start()
{
StartCoroutine(ActivateRoutine());
}
private IEnumerator ActivateRoutine()
{
yield return new WaitForSeconds(4.0f); // and now we wait !
// make a list of all children
Transform[] ChildrenTransforms = this.gameObject.GetComponentsInChildren<Transform>(true);
foreach (Transform t in ChildrenTransforms)
t.gameObject.SetActive(true); // enable all the objects in the list (even the parent)
}
}