Game Development Reference
In-Depth Information
YieldInstruction
When writing a game code, one often ends up needing to script a sequence of events. This
could result in code like the following:
// JavaScript user:
private var state : int = 0;
function Update() {
if (state == 0) {
// do step 0
Debug.Log("Do step 0");
state = 1;
return;
}
if (state == 1) {
// do step 1
Debug.Log("Do step 1");
state = 0;
return;
}
}
// C# user:
int state = 0;
void Update() {
if (state == 0) {
// do step 0
Debug.Log("Do step 0");
state = 1;
return;
}
if (state == 1) {
// do step 1
Debug.Log("Do step 1");
state = 0;
Search WWH ::




Custom Search