Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Multitouch disabled for UI only

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

  1. KristoE

    KristoE

    Joined:
    Oct 13, 2012
    Posts:
    88
    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,602
    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:
    88
    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:
    3
    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 ?