Search Unity

WebGL: detect if Fullscreen

Discussion in 'Web' started by douglassophies, Jul 9, 2018.

  1. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    I have a webpage that embeds an iframe the can be fullscreened. The iframe references my game index file which i have changed to call its parents "fullscreen" button if clicked. This means that when someone clicks the game to start it, it goes to fullscreen. So far so good.

    But i want the game to go to its menu if someone leaves fullscreen and only return to gameplay if its fullscreen again. I tried listening for the escape key and triggering the menu but it seems the browser captures the escape key and does not allow it to reach Unity.

    So instead i am trying to check the status of the game using Screen.fullScreen. But it says it is never fullscreen on build. The editor has the opposite issue of always being fullscreen (but i am less concerned with that.) I also tried setting Screen.fullScreenMode to the various options in the editor. Its value remain -1 no matter what. I have not tried this on a live build to see if it behaves differently.