Search Unity

Multitouch disabled for UI only

Discussion in 'UGUI & TextMesh Pro' started by KristoE, Mar 23, 2015.

  1. KristoE

    KristoE

    Joined:
    Oct 13, 2012
    Posts:
    90
    Hi,
    I was wondering if there is a way to disable multitouch for the UI elements only?
    What I am trying to achieve is use the pinch functionality to zoom in the game, but I don't want the UI elements to stay in the way and trigger.
    The scenario I am looking for is that once you touch the screen with your second finger it would stop sending events to the UI elements.
    Is there a simple way of doing this?

    Thanks in advance
     
    Shahab-Mirza likes this.
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    It's Ironic really but the UI started out single touch only and was updated to support multi-touch.

    There isn't a way using the shipped input modules to restrict touch count, however you can take a copy of the TouchInputModule and change it to be single touch again (or preferably with an editor option to make it single / multiple :D). THen use your new version attached to the event system instead of the default one.
    You can see the code for the Input Modules here:
    https://bitbucket.org/Unity-Technol...ityEngine.UI/EventSystem/InputModules/?at=4.6
     
  3. KristoE

    KristoE

    Joined:
    Oct 13, 2012
    Posts:
    90
    Thanks for the reply, not sure I'll be creating a alternative input module as my project is still in very early production phase and the UI controls are likely to change. Was hoping there was a one line code solution or something, but it seems there isn't.

    Thanks anyways.
     
  4. Shahab-Mirza

    Shahab-Mirza

    Joined:
    Aug 23, 2016
    Posts:
    8
    Today , I am having the same problem . I wanna to disable multi touch on my UI elements but want to Pinch on multi touch. Did you find any solution ?
     
    Serhii-Horun likes this.