- Home /
Input.GetMouseButtonDown(0) works on Android?
Do you know if this statement works out on Android ?
void Update{
if(Input.GetMouseButtonDown(0)){
Destroy(cube);
}
}
Do you actually have a mouse connected to your android? If so, it should.
Answer by vividhelix · Nov 08, 2013 at 06:12 PM
You could change it to this:
if (Input.touches.Any(x=>x.phase==TouchPhase.Began)){
Destroy(cube);
}
Answer by Patrick Kenzie · Nov 08, 2013 at 07:29 PM
Yes, the Input methods like GetMouseButton()
and GetMouseButtonDown()
etc. work on Android and other touchscreens.
However, events like OnMouseDown()
aren't called on mobile devices.
That is incorrect, On$$anonymous$$ouseDown is called on mobile devices with averaged values (which makes it very inconvenient for multi touch). If you just need to react to a touch anywhere on the screen, it's fine. If you need any precision (a touch on a certain part of the screen) you should be using Input.touches.
Answer by LAKSHAYMAVIA · May 21, 2019 at 11:30 AM
if anyone still looking for answere. Instead on Input.getMouseButtonDown() you can use Input.getButtonDown("Fire1") and so on . It works great on mobile and pc.
Your answer
![](https://koobas.hobune.stream/wayback/20220613121432im_/https://answers.unity.com/themes/thub/images/avi.jpg)