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

Getting input touch to work

Discussion in 'Input System' started by Rotary-Heart, Aug 16, 2020.

  1. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    813
    I'm having some issues trying to make the touch system to work with the new input system. This is my current setup:

    upload_2020-8-16_15-47-49.png

    And my testing code:

    Code (CSharp):
    1. void Start()
    2. {
    3.     m_cameraControls = new CameraInput();
    4.     m_cameraControls.Enable();
    5.    
    6.     m_cameraControls.CameraMovement.TouchPoint.canceled += TouchPointOncanceled;
    7.     m_cameraControls.CameraMovement.TouchPoint.started += TouchPointOnstarted;
    8.     m_cameraControls.CameraMovement.TouchPoint.performed += TouchPointOnperformed;
    9. }
    10.  
    11. void TouchPointOncanceled(InputAction.CallbackContext obj)
    12. {
    13.     Debug.Log("Touch Canceled");
    14. }
    15.  
    16. void TouchPointOnstarted(InputAction.CallbackContext obj)
    17. {
    18.     Debug.Log("Touch Started");
    19. }
    20.  
    21. void TouchPointOnperformed(InputAction.CallbackContext obj)
    22. {
    23.     Debug.Log("Touch performed");
    24. }
    The problem is that started and performed are getting executed on start and just once (canceled is never called). Doesn't matter how many tiems I touch the screen they are no longer called. I'm trying to get an Action when the screen receives a new input touch. How can I achieve this functionality?
     
  2. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    813
    Still trying to make this work, currently I have to check for values on update and I will like to avoid this