Search Unity

Question Getting text to wrap correctly with scaling, with vertical layout group.

Discussion in 'UGUI & TextMesh Pro' started by SawyerDM, Jun 6, 2023.

  1. SawyerDM

    SawyerDM

    Joined:
    Apr 19, 2023
    Posts:
    3
    Hey everyone! I'm working on a little tool, and I need to have white boxes with text in them. There are two pieces of text, so I'm using a vertical layout group to organize them, since they're variable in size. However, the text doesn't wrap correctly unless the X scaling of the text is set to 1, even if I set the Vertical layout group to use child scaling. It'll still wrap, but it'll wrap where it would if the text had scale 1. Look below for screenshots. Any help would be appreciated!

    The issue:
    upload_2023-6-6_18-49-24.png

    The UI element with the vertical layout group
    upload_2023-6-6_18-49-47.png

    The problematic text gameobject:
    upload_2023-6-6_18-50-28.png
     
  2. SawyerDM

    SawyerDM

    Joined:
    Apr 19, 2023
    Posts:
    3
    bumping this, hoping for an answer!
     
  3. Epiplon

    Epiplon

    Joined:
    Jun 17, 2013
    Posts:
    52
    Show the hierarchy of these game objects.
     
  4. SawyerDM

    SawyerDM

    Joined:
    Apr 19, 2023
    Posts:
    3
    upload_2023-6-22_17-8-43.png
    I ended up fixing it by having the white box have a content size fitter and some layout elements on the text's themselves, but I recreated the issue here. If I set the X scaling to 1, the text will wrap correctly. However, the panel 'panel' with the vertical layout element, once again controlling child size width and height, and using child scale on width and height, does not force the text to wrap appropriately given the x scaling of the text.