Search Unity

Add a border to an Image with "Preserve Aspect"

Discussion in 'UGUI & TextMesh Pro' started by Ravery, Jul 5, 2022.

  1. Ravery

    Ravery

    Joined:
    Mar 5, 2016
    Posts:
    49
    Is there a way to have a border around an Image with "Preserve Aspect"?
    The "Preserve Aspect" option of an Image changes it's display (not the width/height of the rect transform).
    Adding a child (e.g. sliced image for a border) and making it fill out the entire Image will take the rect transform's width and height into account. Instead of the displayed Image (i.e. modified by Preserve Aspect).

    Is it possible to somehow use the displayed Image's dimensions to change child UI objects' dimension?