WebGL canvas resolution

Hi! When I was testing WebGL build of our application I clicked button that sets fullscreen mode and found that it works not as good as I expected (no offence).

When application is not in fullscreen mode, canvas has resolution 1136:640. That’s exactly, what I see in build settings in unity (resolution and presentation). So it’s 1.775.

When application is in fullscreen mode, canvas has resolution 1680:1049. It’s ~1.6. I understand, that it just uses screen resolution. That’s good when game allows dynamic change of resolution. But currently our game doesn’t support it, so in fullscreen mode I see cropped parts. And this isn’t that nice. So I wanted to ask if it’s possible to enter fullscreen without changing aspect ratio.

Also I have another question related to WebGL canvas resolution. Is it possible to change it’s resolution in runtime? For example, I want to set best resolution for target monitor, but respecting allowed aspect ratio. I found in generated UnityConfig.js file function named SetFullscreen(fullscreen) (from button ‘fullscreen’ on index.html). But it uses some magic that I don’t understand.

2 Likes

Oh, it looks like you can just mess around with this width and height properties of canvas in index.html. Looks like I answered the second question.

1 Like

A selection of embedding templates like Unity webplayer templates would be helpful.

I wanted to put the fullscreen button inside te WebGL player.
At first I have tried to use the SetFullscreen(fullscreen) function mentioned in the above post, but I just could not get it to work.
Then I used a button inside, but - I do not know why - you have to click anywhere on the canvas for the second time to get the button action

Screen.fullScreen = true;

to execute.
http://virtualplayground.d2.pl/WebGL/fullbrowser/

How did you accomplish this? The link you have posted is exactly what I want. I can’t figure out to where to put the following:Screen.fullScreen = true;

Here is the actual example:

The above script line is in the script inside the webgl player.
But this is only for the right - bottom fullscreen button to work.
It hasn’t got anything to do with full browser layout.

Full screen is for full display screen like 1920x1080 if full hd.
Full browser is for the browser window.

I was building to 1280x720, instead of 1920 x 1080. Thank you so much for the help!