ContentSizeFitter - Forcing minimum size?

I’m developing a simple tooltip component. The structure is as follows…

  • Panel - Image, ContentSizeFitter, HorizontalLayoutGroup

  • TMP Text

Here are the panel settings…

The panel properly resizes horizontally as the text length increases.

The problem I’m having is that the ContentSizeFitter appears to be forcing the panel’s initial width to 128 pixels. The panel does get wider when the text is greater than 128 pixels, but it doesn’t scale down to fit shorter text.

When I set “Horizontal Fit” to “Unconstrained”, set the width to 30, and then set “Horizontal Fit” to “Preferred Size” again the panel size is set back to 128.

I need the panel size to be smaller initially. Any suggestions?

Did you ever figure this out? Having the exact same problem.

No. I’m just living with it for now. Annoying little problem.

You need to put a Content Size Fitter on the TMP Text object as well.

I ran into the same issue, struggled for hours. Disabeling the function “auto size” in the text element solved it for me!

So for anyone looking for an answer, the problem comes with the Image, once you have an sliced image with PPUM it will take it as the minimum size, so, make another one as a child, add a layout element to “ignore layout” and stretch it to fill the space