Search Unity

Limited stretching for an element

Discussion in 'UGUI & TextMesh Pro' started by MuHaGames_Avee, Jan 8, 2018.

  1. MuHaGames_Avee

    MuHaGames_Avee

    Joined:
    Feb 25, 2013
    Posts:
    25
    Could anyone advice on what settings should I use for the following scenario?

    So I have a UI object serving as a container (with horizontal layout script) for 3 child objects. Those objects stretch to fill the entire width of its parent and this works ok. The parent is also set to stretch to adjust to different aspect ratios. What I would like to achieve is to allow the parent object to adjust its width - shrink to 5:4, expand as the screen gets wider for 16:9, but maintain the same size as in 16:9 for anything above (21:9 for example). Here's a quick sketch:

    upload_2018-1-8_17-13-41.png
    So basically, I'm trying to find a way to limit stretching of the parent object after it reaches a certain size. I tried using layout element for this (preferred width setting), but either I'm doing it wrong, because I see no effect (in 21:9 the object is stretched to the full screen size no matter what preferred size I set) or it's simply not useful in this scenario.

    Is this at all possible in uGUI alone or should I resort to some kind of custom script that would do it?