Search Unity

Fullscreen in chrome webgl not working properly

Discussion in 'Web' started by therealao, Feb 13, 2017.

  1. therealao

    therealao

    Joined:
    Feb 13, 2017
    Posts:
    5
    Hi folks, building for webgl My fullscreen doesn't seem to scale properly in chrome or opera(i understand opera isn't supported at the moment). When i hit fullscreen it actually gets smaller and I can't seem to find anyone else with the issue.. Firefox works perfectly but whether I use Screen.fullScreen=!Screen.fullScreen; in a unity script or onclick="SetFullscreen(1); in the HTML it doesn't properly fullscreen at all.. The link shows a screenshot of the result of going fullscreen https://imgur.com/gallery/Pxf3J
     
  2. therealao

    therealao

    Joined:
    Feb 13, 2017
    Posts:
    5
    Issue seemed to be resizing in CSS, careful not to resize canvas in css for chrome at least, as this may cause issues when switching to fullscreen
     
  3. wmadwand

    wmadwand

    Joined:
    Jul 19, 2014
    Posts:
    14
    Hi there! Try this one:
    Code (CSharp):
    1. private void Awake()
    2.     {
    3.         switch (Application.platform)
    4.         {
    5.             case RuntimePlatform.WindowsEditor: isFullScreenNow = false; break;
    6.             case RuntimePlatform.WebGLPlayer: isFullScreenNow = Screen.fullScreen; break;
    7.         }
    8.  
    9.         defScreenWidth = Screen.width;
    10.         defScreenHeight = Screen.height;
    11.     }
    12.  
    13. public void ChangeScreenMode()
    14.     {
    15.         if (!IsFullScreen())
    16.         {
    17.             Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
    18.         }
    19.         else
    20.         {
    21.             Screen.SetResolution(defScreenWidth, defScreenHeight, false);
    22.         }
    23.  
    24.         isFullScreenNow = !IsFullScreen();
    25.  
    26.         Debug.LogError(this.gameObject.name + " Was Clicked. Full screen = " + isFullScreenNow);
    27.     }
    28.  
    29. public bool IsFullScreen()
    30.     {
    31.         return Application.platform == RuntimePlatform.WebGLPlayer ? Screen.fullScreen : isFullScreenNow;
    32.     }
     
  4. Deleted User

    Deleted User

    Guest

    Running into the same issue here on Chrome Mobile (clients.. don't ask..), and found this thread.

    The script above gives me a Unexpected symbol `void' error.
    I know this is an older thread, so I hope someone will respond ;)

    thanks!

    rob