Unity 4.6 - VerticalLayoutGroup

This is about the built in VerticalLayoutGroup component in Unity 4.6.

It works fine in most cases, however in certain cases it’s not working for me at all - it positions everything at the same point.

Reproduction steps:

Instead of adding children to the LayoutGroup that are Images or Text add an empty gameObject and add Images or Text to that object.

So instead of:

VerticalLayoutGroup
- Image1
- Image2
- Image3

Have this:

VerticalLayoutGroup
- GameObject with no components attached (doesn't make a difference if RectTransform)
-- Image1
- GameObject
-- Image2
- GameObject
-- Image3

(The dashes indicate the level of nesting).

Now all the images will be positioned at the same place. This makes sense in a way because the container GameObjects do not have LayoutProperties which you can see on any widget gameObject.

So my question is: How can I use VerticalLayoutGroup with children that are not widgets and that have their own widget children?

The use case is this:

I’m displaying a form that has rows of controls, each row consists of an image and text. And the text should be free to expand. If it does expand it should push the rows down below it.

VerticalLayoutGroup (form)
- GameObject
-- Image1 (CheckMark)
-- Text
- GameObject
-- Image2 (CheckMark)
-- Text
- GameObject
-- Image3 (CheckMark)
-- Text

Thanks.

For now it seems the best method is to attach a LayoutElement to the GameObject, and create a script that will update its Preferred Height based on its content size.

Well, there are several ways i guess. The most obvious would be to turn your empty gameobjects into HorizontalLayoutGroups.