简体   繁体   中英

Input.GetPointerDown instead of Input.GetMouseButtonDown?

I was wondering if there was any way to use something like:

if (Input.GetPointerDown) {

instead of

if (Input.GetMouseButtonDown (0)) {

So that I can easily respond to touch controls (tap). Is there any way to do this?

Mouse controls work for touch anyway now. You should be fine continuing to use...

if (Input.GetMouseButtonDown (0)) {}

For evidence, it's used it in this game.... https://play.google.com/store/apps/details?id=com.cosmiccrumpet.numpops&hl=en_GB

I'm going to be changing this soon to use Raycasting instead as I heard it is more responsive, So if you don't like the Mouse controls, maybe you should look more into that.

Also multi touch may be difficult or even impossible through the mouse commands.

Hope this helps :)

Also, for more info, see here:

In unity3D, Click = Touch?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM