What is Unity StartCoroutine ?

If you want to give a time interval before an action is performed in Unity, the "StartCoroutine" method is used.

Let's examine the example below..

public void GoToExit() { StartCoroutine("ExitBegin"); } IEnumerator ExitBegin() { yield return new WaitForSeconds(1f); SceneManager.LoadScene("MainMenu"); }

In our example, when our "GoToExit()" method was called, StartCoroutine directed us to our "ExitBegin" method, which returns the "IEnumerator" interface.

Here too it suspends execution at the specified time (1f - 1 second), using the "WaitForSeconds" class. Afterwards, it directed us to the "MainMenu" screen.



You May Interest

What is Unity IL2CPP ?

What is Unity Sprite ?

What is Unity NPC?

Checking If Unity GameObject Has Child Object

What is Unity Header and Space Feature?