- Home /
Question by
Nobozarb · Oct 15, 2017 at 02:45 PM ·
webglscreen resolutionscreen size
Fill screen with Unity WebGL while maintaining display ratio
I have created a Unity WebGL game, but want to be able to fill the browser window while maintaining a 16:9 height:width ratio. I know I can fill the ratio with this:
<div id="gameContainer" style="width: 100%; height: 100%; margin: auto"></div>
But then it fails to maintain a 16:9 ratio. And for my game, which relies on knocking your opponent off the screen, display ratios are important. I want to be able, for example, to fill the screen width completely and then have the height at 9/16 of the screen width. I have tried this:
<div id="gameContainer" style="width: 96%; height: 54%; margin: auto"></div>
but it does not appear to work. If I could get that code to work, I would be perfectly fine with it.
Comment