Hello, I am having some issues when trying to create a toggle within unity to go fullscreen, Screen.fullscreen=true; This does not work correctly as it requires a extra click after toggling fullscreen for it to actually initialise. I know some people have made externall calls to trigger the default fullscreen toggle html button o something. I’ve been trying to find info on how to do this external call to trigger the fullscreen but I am not finding much.
If anyone has any info on how to accomplish this please let us know.
Well, as @liortal wrote, we set “Screen.fullScreen = true;” before the user doing KeyUp.
There’s a browser limitation - a user must be the one to initiate the fullscreen, so you can enter fullscreen mode only when a user click on the page.
The problem is, Unity is using game loop, and it seems that the KeyUp is called after the user actually did the KeyUp, or at least this is what the browser thinks.
So we check if the user did KeyDown on the FullScreen Button, and call “Screen.fullScreen = true;”, so when the user do KeyUp, the FullScreen mode really happen.
The down side - if the user did the KeyUp outside of the area of the button, it also will enter fullscreen mode. but we didn’t check if we can cancel the fullscreen before that - it was a quick fix.
2) Add this line of code to any Start() funcion in editor
Application.ExternalCall(“OnLoaded”);
Issue I can’t fix (or I would also include fullscreen button):
If you toggle out of fullscreen, canvas size doesn’t update to browser size. I tried to add ExternalCall to fullscreen toggle but it didn’t work.
Im out of time with this project and I don’t have time to find a solution.