Search Unity

How to disable Fullscreen on first click in WEBGL game?

Discussion in 'Scripting' started by qoly, Mar 10, 2020.

  1. qoly

    qoly

    Joined:
    Jun 18, 2019
    Posts:
    12
    I create webgl build, upload to server, and with first click my game turn on fullscreen! How to disable it?
     
    cloutiertyler likes this.
  2. cloutiertyler

    cloutiertyler

    Joined:
    May 12, 2018
    Posts:
    5
    Any luck figuring this one out?
     
  3. Popelsas

    Popelsas

    Joined:
    May 15, 2018
    Posts:
    3
    There is still no solution (
     
  4. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,003
  5. Popelsas

    Popelsas

    Joined:
    May 15, 2018
    Posts:
    3
    In my assemblies, the first click anywhere puts the game in full screen mode. I don't understand what's the matter
     
  6. Popelsas

    Popelsas

    Joined:
    May 15, 2018
    Posts:
    3
    I solved it. In my assembly for WIN, full-screen mode was set in the Start method. In the build for the Web, it worked on click
     
  7. GreatGardna

    GreatGardna

    Joined:
    Jan 9, 2020
    Posts:
    14
    I'm also experiencing this problem, how did you manage to solve it?
     
  8. rahulrathaurkz

    rahulrathaurkz

    Joined:
    Dec 11, 2020
    Posts:
    2
    I was able to stop the Unity WebGL fullscreen default action for my Unity 2019.1.3 project by editing the UnityLoader.js file found in the "Build" directory created when you make a build.

    I removed "(e.requestFullScreen||e.mozRequestFullScreen||e.msRequestFullscreen||e.webkitRequestFullScreen)&&(a.indexOf("Safari")==-1||s>=10.1)?1:0" from the "hasFullscreen:function()".

    B E F O R E :

    hasFullscreen:function(){var e=document.createElement("canvas");return(e.requestFullScreen||e.mozRequestFullScreen||e.msRequestFullscreen||e.webkitRequestFullScreen)&&(a.indexOf("Safari")==-1||s>=10.1)?1:0}

    A F T E R :

    hasFullscreen:function(){var e=document.createElement("canvas");return}

    I have not thoroughly tested this yet on all browsers, but so far it has stopped the "dreaded FullScreen attack" when viewing my WebGL build in Chrome, firefox, Vivaldi and Safari browsers.

    Clearly this is a hack.
     
  9. RiyadhRiseUp

    RiyadhRiseUp

    Joined:
    May 29, 2022
    Posts:
    2
    I solved the issue by removing "hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen" this line in
    [gamename].loader.js file can be found in build folder after the build.
     
    InfiniteDesign8 likes this.
  10. radektesar

    radektesar

    Joined:
    Nov 1, 2017
    Posts:
    2
    I found the problem. Somewhere in my code, I had "UnityEngine.Screen.fullScreen=true;". Remove this code and problem will be solved :).
     
  11. InfiniteDesign8

    InfiniteDesign8

    Joined:
    Aug 22, 2017
    Posts:
    38
    1.[gamename].loader.js file can be found in build folder, open in vscode
    2. copy inside quotes "hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen"
    3.back to vscode, ctrl+find, paste, delete, save.
    4.reup

    thank you
    RiyadhRiseUp