Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Double tap getting (0, 0) position

Discussion in 'Input System' started by TomTobby, Jul 18, 2021.

  1. TomTobby

    TomTobby

    Joined:
    Jun 5, 2017
    Posts:
    1
    Summary
    Using the new input system for UI, when someone taps twice in exactly the same position, the second tap gets the position of (0, 0)

    Testing project details:
    Unity 2020.2.7f1 - Android Build
    Unity Input System Package 1.0.2
    Android device simulator
    Unity device simulator package 2.2.4-preview

    Details of the problem:
    I'm using the new input system package for UI interactions(using the InputSystemUIInputModule) and everything seems to work just fine, except for the part when if you tap multiple times on the same position, only the first will have the real mouse position, the subsequent taps, will have the position of (0,0).
    In the unity editor everything seems to work fine, but you can see the problem using the device simulator package, and of course, the build have that problem too.

    Exemplification:
    I've isolated the problem from my project so you can see what I mean, I've made a Button derived class to get the pointer event data of the click:

    Code (CSharp):
    1. public class TestInput : Button {
    2.     public TextMeshProUGUI text;
    3.    
    4.     public override void OnPointerClick(PointerEventData eventData) {
    5.         base.OnPointerClick(eventData);
    6.         text.text = "Touch at:" + eventData.position.ToString();
    7.     }
    8. }
    And an editor for the class to override the default Button class editor:
    Code (CSharp):
    1. [CustomEditor(typeof(TestInput))]
    2. public class TestInputEditor : ButtonEditor{
    3.     SerializedProperty m_Text;
    4.  
    5.     protected override void OnEnable() {
    6.         base.OnEnable();
    7.         m_Text = serializedObject.FindProperty("text");
    8.     }
    9.  
    10.     public override void OnInspectorGUI() {
    11.         base.OnInspectorGUI();
    12.         EditorGUILayout.Space();
    13.         EditorGUILayout.PropertyField(m_Text, new GUIContent("Text"));
    14.         serializedObject.ApplyModifiedProperties();
    15.     }
    16. }
    17.  
    I've put a button that occupies all the screen:
    Screenshot 2021-07-18 040755.png

    And here's the result:
    Bug.gif

    I hope it's clear too see, GIF files have a really poor quality, and I hope you were able to understand me, English is not my first language

    If you need any more information, please let me know
     
  2. broodysky

    broodysky

    Joined:
    Dec 15, 2016
    Posts:
    2
    Does this problem find a solution? I encountered the same problem.

    Testing project details:
    Unity 2019.4.17f1 - Android Build
    Unity Input System Package 1.1.1
    Android device simulator
    Unity device simulator package 3.0.2-preview