- Home /
Input registering random touches
Hello, I have a canvas which I touch with only 2 fingers, but sometimes Unity is registering a third touch.
Here's the captured image.
My left thumb was pressing position 0, and my right thumb was spamming position 1. At iteration 222, Unity registered a third touch, on position 2.
Any idea how this happens? This bug is killing my game.. Help!
Here's the code of Input Test
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class InputTest : MonoBehaviour, IPointerDownHandler
{
public GameObject textPrefab;
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log("Touch count : " + Input.touchCount);
if (Input.touchCount >= 3) {
for (int i = 0; i < Input.touchCount; i++) {
Debug.Log("Input.touches[" + i + "].position : " + Input.touches[i].position);
//Create UI text to show finger ID
GameObject goTemp = GameObject.Instantiate(textPrefab, this.transform.parent);
goTemp.GetComponent<Text>().text = Input.touches[i].fingerId.ToString();
goTemp.transform.position = Input.touches[i].position;
goTemp.SetActive(true);
}
}
Debug.Log("=== EVENT DATA ====");
Debug.Log("event Data id : " + eventData.pointerId);
Debug.Log("===================");
}
}
if you dont touch the screen at all it also registers some times one extra click? it ALWAYS shows the extra click in the same place? have you test it in other device?
Answer by JJChai · Jul 31, 2019 at 09:35 AM
After testing on some other devices, the bug only happened to my phone. Thanks to @xxmariofer for pointing out.
Your answer
Follow this Question
Related Questions
EventSystem not detecting all UI elements 1 Answer
Can I change the input "submit" and "cancel" button of an eventsystem from a script? 0 Answers
how can i touch the fast objects ? 0 Answers
How do I detect when UI events are triggered on *any object*? 1 Answer
How to solve event triggers blocking scrollview inputs in an inventory/menu? 2 Answers