- Home /
2 Key presses to set panel to visible,UI Panel takes 2 keypresses to become visible
So I have a script attached to the first person controller that comes with unity and when you press escape it sets a UI Panel to visible, however it takes 2 key presses to do so. It does detect the first keypress because I also disable the fps script in the same function/method but for some reason it takes 2 to get the panel to appear. It does this in both the editor and the game build, Any help is appreciated.
void Start()
{
Cursor.visible = false;
panel.SetActive(false);
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
openMenu();
}
}
void openMenu()
{
gameObject.GetComponent<FirstPersonController>().enabled = false;
Cursor.visible = true;
panel.SetActive(true);
}
Your answer
Follow this Question
Related Questions
How can calculate the drawn circle range ? 1 Answer
How can i create array of texture2d with variables names ? 2 Answers
How can i avoid any gameobject overlapping when instantiate the gameobjects ? 0 Answers
Change a variable name only on the Inspector 2 Answers
Calculating Scrolling GameObject x position scrolling pass another GameObject x postion (2D Game) 1 Answer