Hey guys, I’m currently working on a keyboard-based game wtih HTML UIs.
Basically, there is no button or something requires a click inside the unity.
Since my game is keyboard-based, I need some kind of way to acquire focus from web page.
You know, if you don’t click on the unity web player, focus is still on the web page
and that means keyboard input will not be delivered to the web player unless user click on it.
What exactly I need is that, get keyboard inputs when page is loaded. So, here is what I’m asking.
Is there any way to acquire focus from unity side?
Or can I intercept all the inputs on a web page from unity side?
For the last shot, can I render html and javascript on unity web player?
You can trigger javascript from the webplayer on the page it’s loaded.
Once the webplayer is loaded it will trigger a javascript function and maybe you can change focus that way.
I have no idea if thats possible or not.
You can’t renderer anything on top of the webplayer i think.
Unity can’t render a webpage but there are solutions that can ( plugin ). Not sure if some work in the webplayer or not.
Once the webplayer is loaded on the webpage you should be able to trigger a function inside Unity.
Just follow the manual and it should work. I used it even from PHP to Unity and didn’t have problems.
I’ve tried to do this myself and unfortunately failed to find any solution that works in all browsers. I believe that some browsers just explicitly prevent focusing plugins (like Unity webplayer) through Javascript, as a “security” measure. Yes, it sucks, and there isn’t much we can do about it, sorry.