0 votes

I'm learning godot GUI and currently trying to implement a scrolling list with the ScrollContainer. However, no matter what I do, I can't get the ScrollContainer to expand and show child elements - even if I resize in the editor, when I run the game the items within are not visible. If I remove the ScrollContainer, and just have a VBoxContainer with overflowing elements, everything displays OK. I've attached some screenshots that show the scene tree and the resulting game:

ScreenTree

ResultingGame

What am I missing? I'm not sure if I should be setting the Size, MinSize or margin properties in the inspector? Or should the ScrollContainer work all this out on it's own?

in Engine by (12 points)

1 Answer

0 votes

Setting up the scroll container is a bit tricky the first time you use it. Here's how I was able to get it working.

Node Layout

ScrollContainer
    VBoxContainer
        Container

ScrollContainer

  • Set the direction it will scroll i.e. horizontal, vertical
  • Set its default size
  • Set the size flags to be both Fill

VBoxContainer

  • Set its default size ensuring its height is greater than the scroll container's height (adjust values to compensate for the scrollbar(s))
  • Set its minimum size as the same default size values
  • Set the size flags to be both Expand and Fill

Container (Any control node that represents the scrollable items)

  • Set the size flags to be both Expand and Fill

Hopefully this helps.

by (122 points)
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.