1

Inspired in this answer, we have WebGL setup where we want to load webgl template in full screen mode. It is working fine on button click event as below

 <body>
<div class="webgl-content" id="div-parent">
  <div id="unityContainer" ></div>
  <div class="footer">
<button id="buttonClick" style="display:none;" class="fullscreen" onclick="showToggle('unityContainer')"></button>
  </div>
</div>
function showToggle(elem)
  {
    var div = document.getElementById(elem);
    div.style.display = 'block';
    unityInstance.SetFullscreen(1);
  }

Here we have used unityInstance.SetFullscreen(1); in showToggle() function which is getting called on button click. But if we use the same in DOMContentLoaded event its not working. Ex- We are trying as below -

document.addEventListener("DOMContentLoaded", function(event) { 
  unityInstance.SetFullscreen(1);
});

We want to make it full screen without any click event. Can you please guide how can we achieve this?

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
Oxygen
  • 831
  • 4
  • 17
  • 42
  • 1
    You cant. They sid this to avoid browser hijacking. You need the user to instigate it hence you cant just call gofullscreen from unity – BugFinder Apr 01 '21 at 14:29

0 Answers0