Hello! How to disable the button when the game is paused?
The button is a child node of CanvasLayer. Process mode - inherit. I am pausing the game through another child node of the level. The button doesn't perform its functions, but I can still click on it, even if it can't do anything at that moment. I don't want to turn off the buttons manually, and I don't want to give a direct link to CanvasLayer to the node that pauses the game.
How to disable the button when the game is paused
- Edited
If the button inherits from BaseButton, you can set its disabled property to true.
https://docs.godotengine.org/en/4.4/classes/class_basebutton.html#class-basebutton-property-disabled
You could do that in the button's _process() method by checking whether the game is paused.
You will need to set the button's process_mode property to PROCESS_MODE_ALWAYS, so that the _process() method will run even while the game is paused.
https://docs.godotengine.org/en/4.4/classes/class_node.html#class-node-property-process-mode
https://docs.godotengine.org/en/4.4/classes/class_node.html#enum-node-processmode
DaveTheCoder
Thanks for the good advice.
I thought of another method:
Add the button to a group, e.g. "buttons_to_disable".
When pausing/resuming the game, use set_group to set or reset the disabled flag for members of the group.
https://docs.godotengine.org/en/4.4/classes/class_scenetree.html#class-scenetree-method-set-group
you can use acceptdialog window for this. this can be child to main window or canvas layer. using acceptdialog you can disable input for the main window and also disable the button . other options are hit or miss, like adding to a group and it is intensive work as well. if this resolve reply to this message
sstelkar
Thank you. I liked the grouping option. I'll try the acceptdialog option later. I couldn't find tutorials on it quickly, so I'll have to figure it out due to the fact that I don't understand the documentation well.