(Desktop) I want to make it so that when the user re-sizes the game window, the game is stretched to fill the window.
(Similarly, for Android) I want it to be stretched to fit the screen as well.
The game's real resolution is supposed to be 720x1280 (16:9 equivalent). In the image on the left you can see the actual resolution.
I can see that unity automatically re-scales it everytime the game window is re-sized, but it kind of keeps the same aspect ratio. This results in either black bars or part of the game being off-screen. How can I scale my game based on the current window aspect ratio ? I know the graphics will get distorted.
Isn't there a way to stretch the game without keeping the same aspect ratio, within the unity interface ? If not, how could I do that within a script ?
In xna or libgdx, I would simply add a
scale matrix on every
spriteBatch.Begin() method call. That scale would be based on the (current window width, current window height) and the ("real" game width, "real" game height).
For example, since my game is 720x1280, if you had your window re-sized at 500x500, I would scale the graphics by 500/720 on X axis and 500/1280 on Y axis. And then I would have to scale the inputs by
1/scale matrix. I need to know how this works on unity. Perhaps, setting
Camera.main.aspect to the current aspect ratio of the current window (I could calculate that everytime the window is resized), would solve the problem (?), but is there another option ?
I assumed that
supported aspect ratios would do just what I needed. But when I re-size my game window to 720x1080 (4:3 equivalent) down from 720x1280 (16:9 equivalent) it just adds black bars. When I want the game to stretch, in all cases.