Search Unity

WebGL canvas resolution

Discussion in 'Unity 5 Pre-order Beta' started by d12frosted, Dec 24, 2014.

  1. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    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.
     
    FreCre likes this.
  2. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    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.
     
  3. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    481
    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
    Code (CSharp):
    1. Screen.fullScreen = true;
    to execute.
    http://virtualplayground.d2.pl/WebGL/fullbrowser/
     
    Last edited: Dec 30, 2014
  4. impul101

    impul101

    Joined:
    Feb 8, 2013
    Posts:
    21

    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:
    Code (CSharp):
    1. Screen.fullScreen = true;
     
    Last edited: Jan 12, 2015
  5. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    481
    Here is the actual example:
    http://virtualplayground.d2.pl/?p=785

    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.
     
    Last edited: Jan 12, 2015
  6. impul101

    impul101

    Joined:
    Feb 8, 2013
    Posts:
    21
    I was building to 1280x720, instead of 1920 x 1080. Thank you so much for the help!