Game Development Reference
In-Depth Information
}
}
}
}
// C# user: (Put the code inside the class)
GUITexture _restartButton;
void Awake () {
_restartButton =
GameObject.FindWithTag("RestartButton").guiTexture;
}
void Start () {
_restartButton.enabled = false;
}
IEnumerator OnTriggerEnter2D (Collider2D hit) {
if (!_gameEnd) {
if (hit.tag == "Door") {
if (_hasKey) {
_restartButton.enabled = true;
}
}
}
}
Ok, now we are done; click on Play to see what we have. Now, when we collect the key
and go inside the door, we will see a Restart button appear; click on this button and the
game will restart.
Search WWH ::




Custom Search