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

Finding Unity SDK Path

What is Unity Asset Store?

Reaching All Child Objects of Unity GameObject

What is Unity Tag?

What is Unity FBX?