Adjusting for image aspect ratio
Currently, we're ignoring the actual size of the images and making them all fit into a landscape orientation with a 3:4 aspect ratio. Fortunately, we've included the actual (original) pixel dimensions of the image with our ImageInfo
. We can use that now to scale the picture accordingly. We can make this change to the FramedPhoto
script that's on the FramedPhoto prefab.
The algorithm for calculating the aspect ratio can be separated as a utility function in the ImagesData
script. Open the ImagesData
script and add the following code:
public static Vector2 AspectRatio(float width, float height) { Vector2 scale = Vector2.one; if (width == 0 || height == 0) return scale; ...