unity c# wait 1 second code example
Example 1: wait time in unity
using System.Collections;
private void Start()
{
StartCoroutine(Wait());
}
IEnumerator Wait()
{
yield return new WaitForSeconds();
}
Example 2: waitforseconds unity
public void GameOver()
{
levelText.text = "After " + level + " months, you starved.";
new WaitForSeconds(6);
Application.Quit();
}
Example 3: 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);
}