Hey guys,
I'm trying to get my inventory to display properly across different resolutions, but am running into a bit of a snag getting the grid cells for each item to display correctly. The Unity UI Grid Layout doesn't seem to scale at all across different displays even with the Canvas Scaler element. I did find this script (
http://www.justapixel.co.uk/ugui-auto-scaling-grid-layout-code/) which gets me a lot closer. However, there's still a bit of skewing going on with the images on a couple of resolutions. Has anyone else run into this issue and were able to figure out a solution?
Example below of bad skewing at 5:4 aspect ratio:
Example of proper display at 16:9 aspect ratio:
Thanks!
Comments
In general, the aspect ratio set in AC's Settings Manager would need to be read by your UI elements through a custom script if you wanted to adjust them according to it. You can get an API reference to it by right-clicking the field.
In addition, just using the Force Aspect Ratio option in the Settings menu and setting it to 1.7778 for 16:9 is a workaround for making the game display correctly at any resolution. Letterboxing is used in this solution and seems to work best for default AC menus as Unity UI menus can get hidden behind the letterbox if the Rect Transforms are set to anything other than being centered.