Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Skyfish |
Hi,
I’m trying to find a control or a way to have a container open or collapse if you press on the title bar like this: Accordion (GUI) - Wikipedia
The Godot inspector tab in the editor uses this a lot, but I can not figure out how to do it in my game other then custom build. Is there some control or something I overlooked?
I tried a custom solution with a VBoxContainer containing a button and another container.
VBoxContainer
Button
VBoxContainer
Label
Label
Label
Button2
VBoxContainer2
Label
Label
Label
I added an AnimationPlayer to animate the rectscale.y of the inner container.
func _on_Button_pressed():
if(container.rect_scale.y == 1):
player.play_backwards("Accordion")
else:
player.play("Accordion")
It has a nice animation but the ui elements following the shrinked container did not relocate leaving a blank space between the button and the next ui elements. Only if I hide the inside container, the ui updates its positions, but then I can not animate the accordion.
func _on_Button_pressed():
if(container.visible):
container.hide()
else:
container.show()
Any chance you found a solution for this? I want to do exactly the same in my UI.
JSchmalhofer | 2021-06-23 16:14
This is somehow the first result and the linked answer isn’t showing in the top 3 results.
There is a duplicate that got the answer:
How to make folding menu ? - Archive - Godot Forum
Eris | 2023-01-11 15:10