Hi! I’m a beginner and this is my first game ever. I’m having an issue with my pause menu/HUD.
• When I click on a TextureButton, I want my TextureRect to show up and pause the game. Clicking the button again should resume the game, creating a simple open/close menu.
• After a lot of trial and error, the menu works as intended. However, whenever I press the space button, it pauses/unpauses my game. I added a debug print to see when the button is clicked, and it seems the space bar is clicking the TextureButton repeatedly.
What I’ve tried so far, but didn’t work:
Setting Inspector/Mode to none
Checking Project Settings/Input map (space is set up as “jump” for the character)
• The button and the TextureRect are in a CanvasLayer.
The issue activates after I press the menu button at least once, but not before. Additionally, I made the menu work by setting it to Inspector/Process/Mode: Always, as I was previously unable to repeatedly click the button after pausing.
I checked these posts before but couldn’t figure out the issue:
The pause button receives input focus when you first click it.
Afterwards if you press space, it will press the button, as it has focus.
This is useful if you intend to make your UI controllable with a keyboard.
To disable this behavior, you can:
Go to project settings, enable the “show builtin actions” switch and remove the space button from ui_select. Note that this will completely disable pressing space to activate UI elements. You can also assign another key that is more suitable for you.
Set focus_mode on the TextureButton node to None. This will prevent the button from receiving focus at all.