Search Unity

Question ContentSizeFitter not working with TextMeshPro in play mode

Discussion in 'UGUI & TextMesh Pro' started by mortoray, Feb 10, 2023.

  1. mortoray

    mortoray

    Joined:
    Sep 14, 2018
    Posts:
    94
    I have a layout that uses Text TMP, VerticalLayoutGroup and ContentSizeFitter. I have it working in editor mode, where the panel is the correct size, but in play mode (or build-run) the panel shrinks to 0 size (plus padding). I'm so far unable to figure out what the problem is.

    Edit Mode:


    Play Mode:



    Component structure on the panel:


    The items are not editable as I'm creating them via the "Layout Vert Panel" script. As they're created at Enable time, perhaps I need to do something extra to get it working?
     
  2. mortoray

    mortoray

    Joined:
    Sep 14, 2018
    Posts:
    94
    It appears that the Text component is reporting a 0 min-size at runtime, thus trying to shrink to the minimum size gives it no space.

    Is there a way to make the Text component report it's needed size as the minimum size?

    Why is there an inconsistency between editor mode and play mode?
     
    ivoras likes this.