Godot Version
v. 4.5.1
Question
I am trying to make a mockup webpage. I created ScrollContainer and a separate scene, containing VBoxContainer & its children. When I use ScrollContainer with VBoxContainer child and a TextureRect below it, it works fine (i.e. it scrolls). When, instead of TextureRect I use ColorRect, it squeezes it to match the height of ScrollContainer.
How can I make it recognize I don’t want a sqeezed ColorRect but a ColorRect in the size I set? I checked the options in the Inspector for both ScrollContainer and ColorRect, but I wasn’t able to find any related function.
I tried changing ColorRect → Layout → Custom Minimum Size and while it doesn’t scale it anymore (I think), I still can’t scroll it.
Solution
OK, I have stretched the ScrollContainer into the negative coordinates and then was able to stretch it over to the positive as well, later shrinking the negative side, and ending up with a window the expected size.
Not sure why I wasn’t able to expand it in the expected direction at first, but probably Godot prioritized the ScrollContainer’s corners that stretch left and top…
In the ColorRect under Container Sizing, have you tried setting the vertical sizing to Fill?
Another thing to try is to make sure the ColorRect has a minimum size height that is larger that the scrollcontainer height (or that the combined minimum heights of all your elements are larger than scrollcontainer height)
you could also try enclosing the color rect inside another container, like a panel container. Though i’m sure it’s just some sizing parameter that is not set properly.
Thank you for the suggestion. The ColorRect’s Container Sizing is set to fill both horizontally and vertically. Also, the ScrollContainer is 600-ish pixels, and the ColorRect is set to 1500, so way more. On top of that, there is also Label over that ColorRect and the text stretches much below ScrollContainer’s dimensions.
I decided to record screen so hopefully all the data I might have ommited would be easier to spot. Here’s the link to it.
Maybe I’m missing something, but in your video, I see the texture rect is a child of a vboxcontainer that is a child of a scrollcontainer.
But I don’t see in any part of the video where the colorrect is a child of the scrollcontainer.
You’re right. Both ColorRect & TextureRect are children of their own VBoxContainer. That’s why it’s confusing me even more - I thought ScrollContainer should read VBoxContainer’s data and behave accordingly to its properties. However, the only difference between scenes is that VBoxContainer’s child is either TextureRect or ColorRect, so I’d think this is the source of faulty behavior of ScrollContainer.
Each of the VBoxContainer’s Container Sizing is also set to Fill, both horizontally and vertically.
Oh okay my mistake, I didn’t see you have three scroll containers in your main scene.
One thing I noticed is that your bottom scroll containers are not under the Control node. Not sure if it makes a difference, but that’s one difference from the texturerect one.
Can you set the texture rect one to hide, and show one of the scrollcontainers with the colorrect in them?
Yes of course, here you go - TextureRect & ColorRect scenes side by side:
Interestingly, the scene with ColorRect doesn’t look like it’s inside ScrollContainer at all.
As for not being under Control node - the 2nd ScrollContainer is also containing TextureRect, and it works well.
I have just realised the ScrollContainer for ColorRect scene is there - but I can only stretch it in the negative coordinates for some reason… Maybe I switched the coordinates somehow?
OK, I have stretched it into the the negative coordinates and then was able to stretch it over to the positive as well, effectively ending up with a window the expected size. Not sure why I wasn’t able to expand it in the expected direction at first, but probably Godot prioritized the ScrollContainer’s corners that stretch left and top, hence this situation…