- Home /
Input.GetMouseButtonDown not working on WebGL build
I have a project for a client which specifies for a WebGL build to be supplied, but the game breaks as the build does not seem to support the detection of any mouse presses using the Input class, although it does recognise mouse clicks on UI Canvas elements.
I have tried unchecking the 'strip engine code' option in the player settings but that has made no difference.
I am at a loss to know how to debug WebGL but I'm interested to know if anybody could suggest a solution or workaround. I am on Unity 5.5.1p3 on Mac. Thank you.
It should work fine, without needing to do anything special.
The steps I'd take to debug this are:
Does it work in the Editor?
Is it in Update or some other method?
Put a Debug.Log to see if it doesn't trigger at all or if it's just what I'm trying to do that doesn't work (There are some weird instances of this)
If all else fails, and UI canvas works, I'd add a UI element on the whole screen that acts as a makeshift input system.
Answer by Arlocke · Feb 16, 2017 at 10:26 AM
I figured out what the issue was. I was using Input.touchSupported to check whether I should be attempting to use touch or mouse input, and this always returns true on any WebGL build, presumably because the build can't tell what actual hardware is attached, even though I was on a laptop with a mouse.
Don't post answers as comments! Post comment ins$$anonymous$$d...
Answer by imrankhanswati · Feb 16, 2017 at 10:23 AM
you can use Input.GetKeyDown(KeyCode.mouse0); instead.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
WebGL doesn't build 0 Answers
Blank screen on WebGL (Lighting) 0 Answers
do playerprefs work with webgl app? 1 Answer