uGUI Vertical Layout Group stretching objects

Hi,
I’m creating a log console, and I have an gameObject called Content that is an container for text’s messagens. When a message is added to Content, I’m calculating a new size to the panel based on count of messages * height of message RectTransform (I will use an scroll bar when an limit was reached).
I set a verticalLayout on my Content obj to automatically align the messages, and works fine, because I’m recalculating the panel size to fill properly.
If I don’t recalculate, the VerticalLayout is stretching the Text components to fit over all Content size.

Is working fine to me as is, but I would like to know: there is any way to avoid the vertical layout stretching?

Thanks!

[EDIT] Using 4.6 GUI.

I solved this problem using the Layout Group. This is my structure:

  • RootGameObj (VerticalLayoutGroup[ChildForceExpand.Height=false, ChildForceExpand.Width=true])
  • …child1 (LayoutElement[PreferedHeight=true and set the original value to be kept)
  • …child2 (same as above here)
  • …childN (same as above here)

Doing this way the VerticalLayout organized my elements respecting the respective heights of each element.

If you add a Layout Element to your object you can prevent stretching.
Since 4.6 is still on beta there isn’t any documentation for it but for me it works like this:

In order to avoid stretching I changed the Flexible Height to 0(Other values keeps stretching). After setting value to 0, changing the Preferred Height/Min Height will let you change the height.