keep same visible are among all resolutions

Started by
2 comments, last by kburkhart84 8 years, 2 months ago

Im developing a 2d maze game for mobiles and PC, and I want to keep the same visible area, no matter whats the screen size/resolution. I want to display NxM maze cells, but I found that in game preview, if I change the resolution, the visible area changes. How can I solve this? Currently Im using an ortho camera on top of the maze.

Advertisement

Hi rogerdv,

If you're using a container canvas for the scene, and that canvas is using a screen space render mode, try setting the Canvas Scaler UI Scaler Mode to Constant Pixel Size.

I hope this helps!

Note that if you have resolutions of different aspect ratios, it is impossible to display exactly the same number of cells unless you skew the cell sizes. You'll end up with a partial row or column of cells if you scale them up or down to suit the new resolution.

Not Unity specific, but the best way to do this is to scale up until one axis hits the edge, and cover the rest with black bars(or whatever). It can be a general system, which would work both landscape and portrait, though would obviously work better one or the other unless you have a perfect square size. The method of scaling depends on the engine(in your case Unity) but the concept in general applies to all engines.



This topic is closed to new replies.

Advertisement