Search Unity

Aspect Ratio Fitter in Horizontal Layout Group

Discussion in 'UGUI & TextMesh Pro' started by philipp_kuederli_virtamed, Oct 21, 2020.

  1. philipp_kuederli_virtamed

    philipp_kuederli_virtamed

    Joined:
    Aug 25, 2020
    Posts:
    3
    Hello everybody,

    i try to make something very simple. I want in the middle an image with the transparent circle which is scaled with 1:1 aspect ratio to the screen and on the left and right i want to fill the empty space with some black images. However I am not sure if this is possible. I tried already to wrap the middle image into another panel since I have read this somewhere but it seems not to work. Any hints?



    Greetings Philipp
     

    Attached Files:

    Last edited: Oct 21, 2020
  2. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    I don't think the sidebars would work with layout groups/elements, because the circle is resizing and they won't be able to attach to its edge. The only way is maybe with children of the circle, but they won't know where the edge of the screen is, so they can't auto-expand.

    The only way I can understand it working will be like this:
    1.PNG

    You already have an Aspect Ratio Fitter on the CircleImage set to Fit To Parent and 1.

    Set the LeftImage RectTransform to stretch left (click the box picture, then hold shift+alt+click stretch left (bottom-left corner)), then change Pivot X to 1.
    2.PNG

    RightImage is the opposite. Set to stretch right, then set Pivot X to 0.
    3.PNG


    You can set the width of the sidebars to go way off the screen, and way above/below the screen.
     
  3. philipp_kuederli_virtamed

    philipp_kuederli_virtamed

    Joined:
    Aug 25, 2020
    Posts:
    3

    Thank you! I have not yet tried out if it works but its a great hint not to try to put these three in a layout but rather use some hierarchy. Somehow my thinking was not flexible enough at the moment to have this kind of ideas.