Search Unity

Fullscreen toggle does not work inside iframe (Kongregate, other portals)

Discussion in 'WebGL' started by RobbyZ, Apr 21, 2015.

  1. RobbyZ

    RobbyZ

    Joined:
    Apr 17, 2015
    Posts:
    18
    Hello,

    I have noticed that the fullscreen toggle does not function in Chrome 42.0.2311.90m and Unity 5.0.1f1 when the game is embedded inside an iframe.

    You can test this via this simple html:
    Code (csharp):
    1. <!DOCTYPE html>
    2. <html>
    3. <body>
    4. <iframe src="index.html" width=1000 height=700 />
    5. </body>
    6. </html>
    When the game is embedded this way, these methods of going fullscreen seem to have no effect:
    • the fullscreen button below the game
    • Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
    • Screen.fullScreen = true;
    This is problematic since Kongregate and other big portals rely on iframes to embed games into their site. Often the allowed resolution is small, so fullscreen toggle is very useful.

    Is there a recommended workaround, or perhaps I am doing something wrong? Thanks in advance for any insights you can provide :)
     
  2. Doug-Wolanick

    Doug-Wolanick

    Joined:
    Mar 8, 2008
    Posts:
    406
  3. RobbyZ

    RobbyZ

    Joined:
    Apr 17, 2015
    Posts:
    18
    Thanks, but I think that's a different issue - I am making the call on response to a user button click and so fullscreen WebGL does work for me when the game isn't embedded in an iframe.
     
  4. RobbyZ

    RobbyZ

    Joined:
    Apr 17, 2015
    Posts:
    18
    I found that the issue is fixable in my code -- the iframe needs to contain special tags to allow fullscreen usage:
    Code (csharp):
    1. <iframe
    2.    src="index.html"
    3.    width=1000
    4.    height=700
    5.    allowfullscreen=true
    6.    webkitallowfullscreen=true
    7.    mozallowfullscreen=true />
    Now hopefully we can get the big portal sites to include these new tags... ;)