Unity 5 (New GUI)
I have a simple canvas > scrollrect > content container (vertical layout group with vert. fit = preferred size).
My content items are from prefab that is just a panel containing 2 text elements placed horizontally. Text element 1 holds a phrase number and text element 2 holds corresponding phrase. The phrases can be long and often cover multiple lines so the text 2 element is set for horizontal overflow = wrap.
I instantiate and attach my prefab objects in the SceneManager.OnSceneLoaded event of a game controller object script.
Everything seems to work fine except the sizing of the prefab height. I want the height to be calculated based on the text content (which will be anywhere from 1 to maybe 5 lines depending on the phrase length). So working properly I would get a vertical list of different height panels holding the phrase text. However, what I am getting is uniform height for all instantiated prefabs. I have tried about every combination of layout modification I can think of including adding “Content Size Fitters” at some or all the levels and also adding Layout Elements to see if overriding the auto layout on an element would fix it. I get some variation in the output but never close to what I want.
For the new GUI guru’s out there, how should I go about accomplishing this. This seems like a common use case so I would assume the tool can handle it and I am just doing something wrong.