Game Development Reference
In-Depth Information
// C# user:
void Start () {
_isMenuOpen = false;
}
5. Then, we go to the OnGUI function, and we will use the Event class to check if
the user is pressing the correct key.
Note
The OnGUI function acts in a similar way to the Update function, but OnGUI
gets called more than once, for rendering and handling the GUI events, meaning
that OnGUI implementation might be called several times per frame (one call per
event).
// Unity JavaScript user:
function OnGUI () : void {
GUI.skin = customSkin;
var e : Event = Event.current;
if ((e.isKey) && (e.keyCode == KeyCode.M) &&
(!_isMenuOpen)) {
_isMenuOpen = true;
Time.timeScale = 0.0f;
}
}
// C# user:
void OnGUI () {
GUI.skin = customSkin; //Assigning custom MenuSkin
Event e = Event.current;
if ((e.isKey) && (e.keyCode == KeyCode.M) &&
(!_isMenuOpen)) {
_isMenuOpen = true;
Time.timeScale = 0.0f;
Search WWH ::




Custom Search