- Home /
How do I adjust my tilemap for different aspect ratios?
I'm having a difficult time scaling my game to fit different phone device aspect ratios. I have gotten a hang of how to scale UI elements via layout groups and canvas scalars, but I don't know how to scale tilemaps/grids.
My game is based around a grid/tilemap and I'm trying to maintain a 6x7 size grid. I develop using a 1920 by 1080 ratio (portrait), and my grid/tilemap seems stuck in this aspect ratio. When trying out 2960x1440 (portrait) my grid tiles don't fit into the screen (the x axis gets cut off). I tried fiddling with the Camera and I can make the 6x7 fit here by adjusting the localScaleSize, but this makes the grid very small which I don't want. What I want to do is adjust all the cell sizes so that the cells fit the screen in 6x7, whatever the cell size becomes.
How should I approach this?
Answer by datHindLeg · Jul 01, 2019 at 06:49 AM
Found the answer for this: via reddit: https://www.reddit.com/r/Unity2D/comments/c7ju7s/how_do_i_adjust_my_tilemap_for_different_aspect/
Their are three things you can do to fit a different aspect ration, you can decide which works best for you.
Zoom the camera to fit all of the vertical space but scroll to see all the horizontal.
(It sounds like this is what you did) Zoom out to fit all the map but with a lot of empty space on the top and bottom.
Stretch the tiles vertically so the map will fit in the screen but the tiles will be rectangles now. This usually is not what you want but maybe it is.
There isn't really a way you can make a 16:9 map fit a non 16:9 aspect ratio without one of these options. Personally I'd just make it so the player can zoom in or out as they see fit and they can choose if they prefer option 1 or 2 or an even more zoomed in version and they can also change between these at will.
Answer by webjaros · Feb 17, 2021 at 12:26 PM
You can also letterbox the view. Take a look at this tool for example: https://github.com/rabidgremlin/LetterBoxer