Several waiting methods in Unity scripts

1. Use coroutine, define a coroutine to return the WaitForSecods (waiting event) function, start the coroutine in Update, and execute the Show() method after waiting for 2 seconds each time
Insert image description here
2. Use the Invoke() method under the MonoBehaviour class, parameter 1: method name, parameter 2: waiting time; wait for 2 seconds and then automatically execute the show() method
Insert image description here
3...Use the MonoBehaviour class InvokeRepeating() method under, parameter 1: the name of the method to be executed, parameter 2: the waiting time for the first call, parameter 3: the rate of calling the method; execute Show() after waiting for 2 seconds for the first time, and wait for each subsequent time Call the Show() method once per second
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_42186644/article/details/98508833