Content Size Fitter + Wrap Text problems

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!

seems to work here with wrap or with enter (tested on unity 5.5.2p1)

3002719--223871--canvas-wrap.gif

4 Likes

Am I doing something wrong or is this a bug in Unity 5.5.0x1 Collab?

2 Likes

This is how I achived this, I hope it might be of some help :stuck_out_tongue:

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)

  • Horizontal - Unconstrained
  • Vertical - Preferred Size
8 Likes

Thanks for the reply! However, I get the same behavior as I did previously in the OP with this set up.

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 :confused:

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!

I confirmed with Unity staff that this is a bug in the version I’m using right now and is fixed in later versions.

1 Like

Still a bug or undesirable feature in 2017.4.0f

works for me! :slight_smile:
3792994--318328--ezgif-5-c74abe49454a.gif

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!