Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

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:
    69
    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:
    69
    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.