Grid container re-arranges mid-game while disabling visibility via script. How do I keep the button's previous position?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By j5E01

I have a grid container of 5 columns and 5 buttons. I have disabled all other buttons by using .hide() when a button is pressed, but the container treats all other nodes as if they never existed and rearranges the button into column 1 every time…

Is there an option within the engine to keep their current positions?

:bust_in_silhouette: Reply From: Zylann

I think this container doesn’t let you do that at the moment. To workaround that, you may want to replace the nodes by empty controls, or change modulate of your hidden buttons to a transparent color. Or add empty controls which in turn have buttons as children, so you can hide the button while still taking space in the grid. Or maybe write your own container if you are feeling adventurous.

So I found a workaround, for those future duckduckGo’ers:

Use the gridContainer, add the child nodes and set up spacing etc. first.
Then I changed gridContainer type to “control” by right clicking the node from the scene list… This just inherited all of gridContainers spacings without rearranging everything when something becomes hidden or removed.

j5E01 | 2019-11-29 12:55

That’s fine if your GUI does not handle multiple resolutions / multiple languages (in case buttons have text).

Zylann | 2019-11-29 18:33

Hrm. Good point. I’ll probably have to use your method in that case.

j5E01 | 2019-11-30 23:14