unity how to make a coroutine code example
Example 1: unity coroutine
void Start() {
StartCoroutine("func"); // Start coroutine named "func"
}
IEnumerator func() {
Debug.Log("Hello");
yield return new WaitForSecondsRealtime(1); //Wait 1 second
Debug.Log("World");
}
Example 2: coroutine start unity
IEnumerator Start()
{
Debug.Log("Start1");
yield return new WaitForSeconds(2.5f);
Debug.Log("Start2");
}