void start() => StartCoroutine(MyIEnumerator());
IEnumerator MyIEnumerator()
{
Debug.Log("Hello world!");
yield return new WaitForSeconds(3);
Debug.Log("Goodbye world!");
}
IEnumerator wait(float waitTime){ //creating a function
yield return new WaitForSeconds(waitTime); //tell unity to wait!!
}
void Start(){
print("start");
wait(1); ///using function
print("Good night")
}
// This is a new function.
IEnumerator WaitForSeconds(float time){
shouldWalk = false;
yield return new WaitForSeconds(time);
shouldWalk = true;
}
Start(){
Debug.Log("Hi");
WaitForSeconds(10);
Debug.Log("Bye.");
//Here, We are printing Hi to the console, wait 10 seconds, and then print bye to the console.
}