Greetings. I use Unity 5.5.0p4. I have a script that allows the user to drag camera with right mouse button. Code is simple:
if (Input.GetMouseButtonDown(1)
camera.controller = new MouseBasedCameraController(camera);
(Variable “camera” is a wrapper for Unity camera)
Script with this code is attached to a valid, enabled GameObject and is called from its Update method. I tested it in editor and it works.
Then I compiled the game for WebGL and this did not work.
I changed the code:
if (Input.GetMouseButtonDown(1) {
camera.LookAt(400, 400);
Debug.Log("works");
}
So if condition is true, camera looks at empty space and debug console shows the word “works” and I can say does input work or not. I tested different types of input and there are results:
- Clicking GUI Buttons, typing text in Input Fields: works both in editor and WebGL.
- Input.GetMouseButton, GetMouseButtonDown, GetMouseButtonUp, mousePosition: works in editor, does not work in WebGL (all buttons).
- Input.GetKey, GetKeyDown, GetKeyUp: does not work at all, debug console shows nothing.
How to solve my problem?