Detecting when user goes fullscreen in web player

Hi Forum

The title says it all. Is it possible?
I could use something like OnResolutionChanged().

Thanks
~ce

if (Screen.fullScreen == true)
{
}

Thanks Daniel.

So, I suppose that I should check if Screen.fullScreen changes on each update by comparing the current with the last value … or is there a even smarter way?

~ce

This is not really very clever, but might be helpful nonetheless…

I want to only check fullscreen in the webplayer (and not in a standalone build), so I use a coroutine that checks if the player changes resolutions in a webplayer. Notice that the coroutine doesn’t start in a standalone build or in the editor because it isn’t necessary in those situations:

function Start () {

if (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer)
	RealTimeFullScreen ();

}


function RealTimeFullScreen () {

	var fullState : boolean = Screen.fullScreen;
	while (true) {
		while (Screen.fullScreen == fullState)
			yield;

		fullState = Screen.fullScreen;
		SomeFunction (fullState); // This function gets called once when we enter or exit fullscreen
	}
}

Thanks Danny, it’s pretty much what I ended up doing. I would prefer a build in event handler for fullscreen changes, but I can live with this solution.

~ce

Another possibility is to disable the context menu, and implement full-screen switching yourself. That way you don’t have to poll Screen.fullScreen for going full-screen, although the user can still switch back at any time.

–Eric

Aha! Now we’re talking. I’ll just throw the reference for the sake of archiving:
http://unity3d.com/support/documentation/Manual/WebPlayerBehaviorTags.html

Thanks Eric
~ce