unity wait for seconds

Code Example - unity wait for seconds

                
                        void start() => StartCoroutine(MyIEnumerator());

IEnumerator MyIEnumerator()
{
	Debug.Log("Hello world!");
    yield return new WaitForSeconds(3);
    Debug.Log("Goodbye world!");
}
                    
                
 

Time delay csharp unity

                        
                                void start()
StartCoroutine(Text());

IEnumerator Text()  //  <-  its a standalone method
{
	Debug.Log("Hello")
    yield return new WaitForSeconds(3)
    Debug.Log("ByeBye")
}
                            
                        
 

wait in unity

                        
                                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")
    }
                            
                        
 

waitforseconds unity

                        
                                public void GameOver()
		{
			//Set levelText to display number of levels passed and game over message
			levelText.text = "After " + level + " months, you starved.";

			new WaitForSeconds(6);

			Application.Quit();


		}