FullScreen in browser

Hey everyone, I build a PWA WebGL build and my fullscreen script is this simple method:

using UnityEngine;

public class FullScreen : MonoBehaviour
{
public void ToogleFullScreen(bool isFullScreen)
{
Screen.fullScreen = isFullScreen;
}
}

the problem is when I press the button, I have to click or press a key then the full screen is applied but the F11 key works just fine. I even upload a test project here

websites are not permitted to go full screen without user interaction

1 Like

Thanks bugfinders.
That’s a bummer!! shouldn’t pressing a button in the unity canvas be considered as a user interaction? it is just irritating that the user should click somewhere else to apply the fullscreen! is there a work around for it, I don’t know can I fake a user input or something after the button is pressed?

i think the reason your stuff isnt working is that the first click is actually focusing the game also i can click your “full screen” button twice and it goes full screen, so its like the bool is incorrect.

for example take my PoS i really ought to work more on it game
https://sillygames.online/DungeonDisasters/index.html

All you need do is press space and mine leaps to full screen

1 Like

Yes. This is a side effect of how input is handled by UGUI. See if this works for you.

https://discussions.unity.com/t/645964/3

1 Like

Hey there. I have a free asset that might help you. You can also check all of my assets .

1 Like

thanks for the great free assets, a minor bug though the buttons won’t change when I go fullscreen with the F11 key.
I tested on Google Chrome and my Unity version is 2022.3.4. but it seems to handle all the other scenarios. (I just built your example scene.)