Preserve Aspect Ratio of Source Image

I have an image where I am using code to change the sprite in the image. The problem is that sprite A’s aspect ratio does not match sprite B’s aspect ratio. Is there a way to tell unity to just maintain the aspect ratio of the sprite?

All the suggestions I have found was to use Aspect Ratio Fitter, but that seems to maintain the aspect ratio the image is initially set to, and not the aspect ratio of the sprite being loaded into the image.

I figured it out, the trick is that you have to add a sprite to the image first (does not have to be the correct sprite). This causes the preserve aspect option to appear, just check that.

1 Like