- Home /
Focusing the UnityPlayer
We're using Unity 2 with the unity 3.x based browser plugin, and we're having trouble focusing this. I found bits and pieces of information and similar problems, nothing that really helps me.
The problem is, we have a play button that appears when Unity is paused, which appears where Unity would normally be. Clicking this button sets the visibility css property to "visible" (as it was hidden). But then you still need to click on the Unity Player one more time to allow keyboard events through again (ASWD movements).
I've tried setting the webplayer's focus with:
document.getElementById('UnityObject').focus();
It seems to work in IE8, but not in Firefox 3.5 or 3.6 or Chrome 8.
Well, it's a matter of security. Browser plugins should not be allowed to s$$anonymous$$l the focus and they normally have a security button (ESC in unity) that free the mouselock. Since $$anonymous$$icrosoft products don't really stick close to the current standards it may work in I$$anonymous$$ It's quite similar to the Flash-plugin. That's why most games show a "play" button inside the game to force the user to click on the plugin and set the focus.
Answer by Waz · Apr 20, 2011 at 11:10 PM
Obviously you could just put the pause button in Unity rather than HTML, so I assume you have a good reason (eg. performance). But you could put the pause button in Unity and use focus/blur events to show/hide the plugin (and have your current HTML button to attract the user to focus).
Your answer
Follow this Question
Related Questions
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Can't install Unity WebPlayer HELP ! 2 Answers
Streaming video to movie texture in web player 0 Answers
Web player 1 Answer
Help with Binary serialization/de-serialization of List items and the WEBPLAYER 1 Answer