Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question LayoutElement Max Size? Need help auto resizing a box with text

Discussion in 'UGUI & TextMesh Pro' started by zevonbiebelbrott, Nov 28, 2023.

  1. zevonbiebelbrott

    zevonbiebelbrott

    Joined:
    Feb 14, 2021
    Posts:
    118
    I have a tooltip box which i want to have a max size of 300.
    The tooltip box should automatically resize to the smallest possible size.

    This behaviour seems impossible to accomplish with LayoutElements and LayoutGroups.
    If there was a max size setting it would be trivial.

    Heres what my box looks like:

    Correct behaviour, but only when content text is small:
    TooltipOne.png


    Still correct due to GridLayoutGroup Flexible Colum/Row settings working out in this case.
    TooltipTwo.png


    As I increase the context text, it starts to break...
    Content box should have a max of 300 and then expand downwards, but it expands horizontally indefenitely:
    TooltipThree.png


    If I add a LayoutElement to Context Text it will stay at that max size and expand the whole box even though content text is much smaller. (Still broken)
    TooltipFour.png
    If I make the same LayoutElement's preffered size smaller it again breaks... Instead of expanding untill 300 and then going down it just goes down immediately...
    tooltipFive.png

    Continued in next post as Unity does not allow more than 5 images per post for some reason...
     
  2. zevonbiebelbrott

    zevonbiebelbrott

    Joined:
    Feb 14, 2021
    Posts:
    118
    Heres my Content GameObject settings (parent of Text Element im trying to fix):
    ContentParent.png

    Changing Child Force Expand doesnt change anything, On or Off behaviour is the same.


    Heres the Tooltip GameObject settings (parent of everything, whole box):
    TooltipParentOfEverything.png

    Changing preffered Width to 300 and leaving Flexible Off/ at 0 also doesnt work
    Again setting Child Force Expand On or Off does not change the behaviour or produce the behaviour i want...


    Any help is appreciated...

    Thanks.
     
    Last edited: Nov 28, 2023
  3. zevonbiebelbrott

    zevonbiebelbrott

    Joined:
    Feb 14, 2021
    Posts:
    118
    Content cope