D
D
DstivjTS2018-02-02 16:06:18
Unity
DstivjTS, 2018-02-02 16:06:18

Input.GetTouch(0) vs Input.GetMouseButton(0), which is better to use in mobile devices?

I use Input.GetMouseButton(0) for screen touch detection, is this correct and will it affect performance? It seems that everything is working fine, except for detecting a finger on the screen, nothing else is needed (swipe, multitouch, etc.).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2018-02-02
@DstivjTS

The difference will be only when you touch the screen with two fingers or more, in this case GetTouch will give the fact of pressing with the first finger, while you can remove it and leave the rest on the screen, and they will still be the second or third and so on. GetMouseButton will not distinguish between fingers and will only respond to the very fact of clicking (most likely, the last time I checked it was a couple of years ago). In your case, you can use any method, there will be no difference in performance. Just keep in mind that Input does not interact with the UI in any way, which can lead to the fact that when you press the buttons, your logic will work once again.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question