- Home /
In Game Pause Menu Keydown Issue
Hi All,
EASY TO ANSWER READ THIS PLEASE!
I've decided to write my own pause menu script when a key is pressed by I'm using the function properly. Currently the my pause menu will be called when any key is pressed, but I want to make it a specific key, like M
Here is my script
// Detects keys pressed and prints their keycode
function OnGUI() {
var e : Event = Event.current;
if (e.isKey) {
Debug.Log("Detected key code: " + e.keyCode);
var MainMenu = GetComponent("MainMenu");
MainMenu.enabled = true;
Time.timeScale = 0;
Screen.lockCursor = false;
}
}
This is bound to be an easy question to answer
Answer by kr1ska · Apr 17, 2011 at 05:39 PM
// Detects keys pressed and prints their keycode
function OnGUI() {
var e : Event = Event.current;
if (e.isKey && e.keyCode == KeyCode.M) {
Debug.Log("Detected key code: " + e.keyCode);
var MainMenu = GetComponent("MainMenu");
MainMenu.enabled = true;
Time.timeScale = 0;
Screen.lockCursor = false;
}
}
Here is the list of the key code aliases: http://unity3d.com/support/documentation/ScriptReference/KeyCode.html
Thank you, I did it another way, by using
// Detects keys pressed and prints their keycode function Update() { if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.$$anonymous$$)) { var $$anonymous$$ain$$anonymous$$enu = GetComponent("$$anonymous$$ain$$anonymous$$enu"); $$anonymous$$ain$$anonymous$$enu.enabled = true; Time.timeScale = 0; Screen.lockCursor = false; } }
..but this is useful too because it still calls to the debug
Your answer
Follow this Question
Related Questions
Pause Menu 3 Answers
Pause Button Menu loader 2 Answers
How to disable pausing on main menu drop down? 0 Answers
hi i just got the ultimate fps camera and it is not compatible with pausemenus 0 Answers
Restart Problem 1 Answer