wait for a second unity code example
Example 1: wait for seconds unity
Start()
{
StartCoroutine(Example());
}
Example()
{
Debug.Log("Hello");
yield return new WaitForSeconds(3);
Debug.Log("Goodbye");
}
Example 2: unity wait for seconds
void start() => StartCoroutine(MyIEnumerator());
IEnumerator MyIEnumerator()
{
Debug.Log("Hello world!");
yield return new WaitForSeconds(3);
Debug.Log("Goodbye world!");
}
Example 3: waitforseconds unity
public void GameOver()
{
levelText.text = "After " + level + " months, you starved.";
new WaitForSeconds(6);
Application.Quit();
}
Example 4: wait for a second unity
void Start()
{
StartCoroutine(ExampleCoroutine());
}
IEnumerator ExampleCoroutine()
{
Debug.Log("Started Coroutine at timestamp : " + Time.time);
yield return new WaitForSeconds(5);
Debug.Log("Finished Coroutine at timestamp : " + Time.time);
}