Search Unity

Resolution independent, scrollable list of Images with aspect ratio

Discussion in 'UGUI & TextMesh Pro' started by Deckweiss, Nov 22, 2017.

  1. Deckweiss

    Deckweiss

    Joined:
    Nov 22, 2017
    Posts:
    5
    For my cross platform project I want a scalable menu.
    The text size however should stay the same visual angle size. So on a smaller resolution screen, the text will be relatively large on the buttons, while on the larger ones, it is smaller.

    I've achieved this by setting a constant pixel size on the canvas scalar and by adding the paddings between buttons and positions of each element by using anchors.
    (As you can see in the left button arrangement)


    I need a scrollable list of loadouts for the player, on the right side of the screen, which are represented by a background image, a label and a small edit button.

    The problem is, that I can not find any way to keep the aspect ratio of the background image, while stretching it to the width of the scroll view. When the image is shrunk down to fit the scroll view, the height of its rect transform stays at the native size of the image.
    (As you can see in this screenshot: https://puu.sh/yrxOW/dbbd2623e2.png)


    Is there any way for me to achieve the desired behavior without having to write custom scripts?

    Interestingly enough tasks as such can be done in html+css, javaFX and android development in a MUCH easier fashion, so I wonder why unity is lacking in that aspect.


    Important note:
    (I do not own the images used in the attached unitypackage and screenshots. I've used them for the private purpose of visualizing how the finished gui should be looking in a quick and dirty manner)
     

    Attached Files:

    Last edited: Nov 22, 2017