Web Player ignore input if doesn't have focus

Is there a way to keep a game running in the background, but have it ignore user input? I.e. is there a flag that I can check whether the game has focus or not? Or some other mechanism to achieve this?

This actually seems to work okay everywhere except OS X on Safari.


Maybe you can try OnApplicationFocus or OnApplicationPause?

I had some focus problems on Mac today: Unity didn’t register mouse down events on the left 2/3rds of the screen (though registered mouse moves normally).

Though it previously worked well, it started (I guess) with a new player version.

The problem was me messing with DIVs on the HTML page while Unity was loading (showing the alternative content when no player installed etc.) So, if you got focus problems, it might be because of your custom host page!

Also, use always the latest version of UnityObject.js, e.g. always like to the online version of the script (on Unity servers), because Unity team could update the script to make it work with a new player version.

Safari has a bug related to sending focus messages to plugins, which may be causing this. You can test this, does the problem go away if you set Safari to 32-bit mode in the info panel in the Finder? If it does, then it is this known Safari bug (which I have reported to Apple).