+1 vote

I have recently been diving into Godot's UI. I have found nearly everything I would need supported through nodes, apart from one thing:

I want to create a UI panel, in game, that allows the player to rescale it horizontally or vertically, to their desired height/width.

Basically as any Windows application can be resized, or in the way that Hsplit/Vsplit work, but then at the edges of a window. Someone asked this before a few months ago, and had some great visual examples: Create Resizable Window - Godot Q&A

Is something like this support natively through Godot, or would I have to make this myself (through collision boxes & Gscript). And if so, does anyone have any suggestions on how to tackle this?

Thanks in advance!

asked Sep 11, 2019 in Engine by Arecher (21 points)

1 Answer

+2 votes
Best answer

The Godot editor itself is made with the same nodes you can use in a game. Some of the windows in here are resizeable, so it's definitely possible to make a resizeable panel.

The built-in way is to use the WindowDialog class, which has a resizeable flag out of the box. If the title bar annoys you, you can re-style it by changing the styleboxes in the inspector.

answered Sep 11, 2019 by Zylann (26,153 points)
selected Sep 11, 2019 by Arecher

I cannot believe that I missed that one. Thanks a bunch!
I'll go experiment with it, and see if I can modify it to my needs!

if you have problem with that X button for closing that remains after removing bar - I used this :

remove_child(get_children()[0]) 

to ged rid of it.

Rafiz, don't do this. It will make the node leak and it's not guaranteed to always be the first child in future versions.

To turn it off, you could do this instead:

get_close_button().hide()

https://docs.godotengine.org/en/stable/classes/class_windowdialog.html#class-windowdialog-method-get-close-button

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.