The nvoke() method is a delegation mechanism of Unity3D. For
example: Invoke("SendMsg", 5); It means: call the SendMsg() method after 5 seconds;
use the Invoke() method to pay attention to 3 points:
1: It should It is called in (Start, Update, OnGUI, FixedUpdate, LateUpdate) in the life cycle of the script;
2: Invoke(); methods with parameters cannot be accepted;
3: When Time.ScaleTime = 0;, Invoke() is invalid Because it will not be called
Invoke() also supports repeated calls:
C# code
- InvokeRepeating("SendMsg", 2 , 3);
This method means: call SendMsg () method after 2 seconds, and then call SendMsg () method every 3 seconds