Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to keep aspect ratio for children in an Horizontal Layout Group?

Discussion in 'UGUI & TextMesh Pro' started by Neil_McCormack, Dec 11, 2020.

  1. Neil_McCormack

    Neil_McCormack

    Joined:
    Apr 18, 2017
    Posts:
    1
    Hi everyone,

    I'm having a really dull issue: I have a Horizontal Layout Group inside a Vertical Layout Group. My Horizontal Layout Group is supposed to align Images next to each other like this:



    While they currently do this:



    This is due to one thing: I need my letters (UI Image) to have an aspect ratio of 1:1.

    So I have child force expand on my Horizontal Layout Group so I can have my letters as wide as they are tall (if I don't they won't have the height of my Horizontal Layout Group.)
    I've also tried (amongst other solutions) to put Aspect Ratio Fitter on my letters but it doesn't work since it overrides my Horizontal Layout Group and it adds letters out of my screen bounds without setting them as a correct size...

    I feel like I've searched for solutions everywhere so I ask my question here, if you have a solution or even a hint I would be so grateful.

    Thank you,

    PS: Here are my settings