There are two built-in delay methods in MonoBehaviour
Invoke
1
2
3
|
Invoke(methodName:
string
, time:
float
):
void
;
methodName:方法名
time:多少秒后执行
|
InvokeRepeating
1
2
3
4
|
InvokeRepeating(methodName:
string
, time:
float
, repeatRate:
float
):
void
;
methodName:方法名
time:多少秒后执行
repeatRate:重复执行间隔
|
There are also two important methods:
- IsInvoking: used to determine whether a method is delayed and is about to be executed
- CancelInvoke: Cancel all delay methods on the script (note that gameObject.SetActive(false) does not work, which is the difference from Coroutine)
There are two built-in delay methods in MonoBehaviour
Invoke
1
2
3
|
Invoke(methodName:
string
, time:
float
):
void
;
methodName:方法名
time:多少秒后执行
|
InvokeRepeating
1
2
3
4
|
InvokeRepeating(methodName:
string
, time:
float
, repeatRate:
float
):
void
;
methodName:方法名
time:多少秒后执行
repeatRate:重复执行间隔
|
There are also two important methods:
- IsInvoking: used to determine whether a method is delayed and is about to be executed
- CancelInvoke: Cancel all delay methods on the script (note that gameObject.SetActive(false) does not work, which is the difference from Coroutine)