top of page

Coroutines-005 Start Method as Coroutine

Project Files for the course - Download

1.1 Introduction

1. In this tutorial we are going to learn how to use Start Method() to start a coroutine.

2. We can use coroutines with Unity's built in function like start method.

3. Open the Scene005 folder to get started.

1.2 Start Method as coroutine.

1. Let us write the start method.

image.png

2. To make start method into the coroutine we just need to change its return type to IEnumerator and it works as a coroutine and is called by the Unity.

image.png

3. Let us add few more statements to the start method and test this in Unity.

image.png

4. As you can see from the code we have added few print statements along with a wait time between each of them.

5. Let us now test the code in the Unity Editor.

image.png
image.png

6. On running the code we can see that the three statements are printed even without calling the start method(called on its own by unity).

image.png
bottom of page