Game Development Reference
In-Depth Information
The preceding code will have a similar result without having a new variable and an extra
if
statement to check for each step event.
You can also pass special values to the
yield
statement to delay the execution of the
Update()
function until a certain event has occurred, such as
WaitForSeconds
,
WaitForFixedUpdate
,
Coroutine
, and
StartCoroutine
.
Tip
You cannot use
yield
from within
Update()
or
FixedUpdate()
, but you can use
StartCoroutine
to start a function that can use
yield
.