An App I’m working on, has an issue whereby, opening the page with the Unity plugin via Chrome - has all keyboard input disabled. Sometimes this effect is temporary and keyboard input returns, other times keyboard input is disabled on the page indefinitely.
Does anyone have any similar experiences? Solutions to this problem?
Here are some more techy details…
This line was added:
if(!string.IsNullOrEmpty(Input.compositionString) || !string.IsNullOrEmpty(Input.inputString))
Debug.Log("Input.compositionString: " + Input.compositionString + ", Input.inputString: " + Input.inputString);
which should print out any keyboard input.
When the bug occurred it wasn’t printing out anything. i.e no keyboard input was being reported to the game.
This line of code was definitely still be executed as the caret was still flashing.
Are you sure you have actually “clicked” into the webplayer? The webplayer is lika a control. When it’s not the active one it doesn’t receive key input. That’s actually true for most browser plugins. This is even an important security feature. Otherwise if a player has a unity game open in another tab while he’s doing some online banking the game could keyspy the login data…
Even when on the same page (which could actually have multiple unity plugins in it) you always have to “make it active” by clicking on it. Take a look at the iTween example page. The “Path-constrained Characters” example uses keyboard input. They made it so when you click on it the webplayer loads and is activated automatically. But if you click for example in the address bar and then on the background of the webpage, the keyboard input won’t work anymore. You first have to click again into the plugin area.
edit
The iTween page is actually a bad example Unless you left the page at least once they kind of lock the input to the last active plugin. Here’s one of my examples. There you can clearly see when you click outside of the plugin you loose the keyboard focus. Once you click inside it’s back.
IMPORTANT
The webplayer has another security feature. It will release the keyboard focus and mouse locks when the user presses ESC. You should never use ESC as a key in your game. It’s the emergancy key to quit fullscreen. This key will ensure the user gat back the control of his browser / PC.
2. edit
Hmm actually i wes wrong. ESC just frees the mouse and disables fullscreen but keep the keyboard focus.