I'm coding my first prototype in Godot, and I'm loving the engine so far. My game is a turn-based management sim that involves "cards" that one selects to add to a tableau. Right now I have everything in one tree/scene: a Controller root node, with the UI and data nodes sitting underneath it.

I switch back and forth between the pick-card UI and the place-tableau UI by hiding the pick-card UI buttons and showing the tableau UI, and vice-versa. It seems easy, and it works fine, as hiding a button apparently disables it. But is it bad practice to do it this way? Should these interfaces be two different scenes?

Thanks in advance!

It's probably fine to use visible for this, I've done this many times to hide/show UI elements and even entire UI screens. Ultimately the key to remember is that it will still process code in _process and _physics_process, even if not visible, so you don't want to have any performance intensive functionality going on in the background if it's going to be unused, but adding something like if (visible == false): return to the beginning of _process or _physics_process would fix it.

Thanks for your reply! OK, that sounds pretty reassuring. I'll keep playing around with it. Thanks again!

This should be fine, and it is more optimized than destroying and recreating objects. However, if you have a large number of cards (like in the thousands) then it may require more care, since they will all exist in memory.

Thanks for your reply. I plan to have only a hundred cards or so, but I suppose there's a chance I'll get carried away and create more. I guess I'll see how it goes. For now, at least, it's working nicely.

Godot's UI tools are awesome, by the way! Fun to use and powerful.

Hmm, I'm having a new issue: some (all?) of the hidden UI controls (Buttons) retain focus, even if I call .release_focus(). In every case I've used the Input Map to add a keyboard hotkey along with a mouse-click. I've tried using .grab_focus() on the top control node, or on a sister control node, but that doesn't seem to help.

Actually, I have trouble seeing which of my UI controls has focus -- only one at a time can, right?

Anyway, can anyone suggest what I might be missing? Thanks in advance.

When I disable a button, I also set its focus mode to none to keep it from getting focus. I haven't had to do that for hidden buttons, though.

btn_load.disabled = true
btn_load.focus_mode = Control.FOCUS_NONE

Thanks for your reply. That did work -- but then I realized I'm an idiot, hehe. In one case, I had cleared the texture of a textureButton whose texture changes frequently, but I had not touched the .visible property. It was causing a cascade of UI chaos, lol. I set that button's visibility to false, and that fixed it.

Thanks again!

Usually what I do is just call remove_child() and then when I want it back call add_child(). As long as you have a variable saved with this object it won't get destroyed, and any scripts on the object will stop running in the meantime without doing anything special. And when you call add_child() it will be in the same place and everything should pick up where it left off.

I didn't know remove_child() worked that way. I'll give it a try. Thanks.

a year later