To avoid any XY problems here’s my Goal: I"m trying to create a TextViewer that expands and contracts dynamically and is scrollable. I accomplished this by doing the following:
Created a Panel named TextView and added:
Components:
— ScrollRect
— Content set to: Text (defined below)
— Vert Scrollbar set to: Scrollbar (defined below)
— Rect 2D Mask
— Horizontal LayoutGroup
— Force Expand Height Checked (Width Unchecked)
Children:
UI Text named Text:
— Layout ELement
---- Flexible Width: Set 1
---- Content Size Filter
— Vertical Fit : Preferred Size
UI Scrollbar named Scrollbar
---- Layout Element
Min Width: 20
This works perfectly fine and the TextBox does expand and contract as I add/remove lines from its Text field. However the Content Fitter inside of it has this big warning:
“Parent has a type of layout group component. A child of a layout group should not have a Content Size Fitter component since it should be driven by the layout group”
Is there a better way to accomplish my goal? Will having a content fitter inside a child of something with a horizontal layout cause problems later if I’m using this as a prefab in more complicated layouts later? I tried using a content fitter inside the parent (TextView) but this just caused it to expand to the full size of the child Text which i definitely do not want.