So I’m making a tool tip that will have text that is dynamically added. Right now I have the following set up:
Parent:
Rect Transform - Width = 200
Content Size Fitter - Horiz Fit = Unconstrained & Vert Fit = Preferred Size
Horizontal Layout Group - Force Expand = false & Child Control Size = true
Child Text
Text Component - Horiz Overflow = Wrap
This works as intended as far as if I press the enter key the parent expands vertically to fit the new line of text, however if I create a new line from the text wrapping (rather than pressing enter) the parent does not expand vertically to fit the new line of text.
Also I noticed that when text is wrapped the preferred height of the text layout component remains unchanged.
Any ideas on how I can get the parent to expand vertically to fit the new lines of wrapped text?
I’ve looked all over but I can’t seem to find a solution to this. Thanks in advance for your help!
This is how I achived this, I hope it might be of some help
PARENT
Vertical Layout Group:
Child alignment - Upper Left
Child Control Size - [×] Width - Height
Child Force Expand - [×] Width - Height
(You should add some padding too)
Content Size Fitter:
Horizontal - Unconstrained
Vertical - Preferred
CHILD TEXT
Text:
Horizontal Overflow: Wrap
Vertical Overflow: Truncate
Content Size Fitter (This gives a warning, but it’s ok, since the parent Layout group only restrains horizontal axis, and here we restrain the vertical axis)
Mmm… When you set the Vertical Overflow to Truncate, does your text keep drawing outside the boundaries or it disappears? I’m asking this because I can’t see the lines delimiting your Text in your gif, so I think that the problem might be that your Text is not resizing.
I also think that this may be a bug with your version, since I tested it on 5.5.0p1 and 5.4.2p3; and @mgear tested it on 5.5.2p1
Yes that is accurate. My text is not resizing as it should. I guess its just a bug in my version? I’ll send over a bug report. Thanks for the help guys!
THIS is the real deal! Yes, we can and need to ignore the warning if the layout groups in the parent does not impose layout constraints in the axis we want to auto size. Thanks!