- Home /
Unity UI handling 2 touches
Here is my code:
using UnityEngine;
using UnityEngine.EventSystems;
public class PointerDownTracker : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public static bool pointerDown = false;
public void OnPointerDown(PointerEventData eventData)
{
pointerDown = true;
}
public void OnPointerUp(PointerEventData eventData)
{
pointerDown = false;
}
void Update () {
Debug.Log (pointerDown);
}
}
I have this on an image on the canvas. When I touch the image with my finger, it prints out "true". When I release it, it says "false"
However, when I hold a different part of the screen and then touch the image, nothing happens. How can I do it so that 2 touches are tracked? I wanted to be able to touch 2 different images at the same times and still call independent functions. However, when I touch one, the other one can't be touched.
Answer by Wolfdog · Jun 03, 2015 at 04:47 PM
The problem was that Windows only supports 1 pointer at a time. After compiling it and trying it on android, everything was fine.
Your answer
![](https://koobas.hobune.stream/wayback/20220613195728im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unable to follow UI transition HOW-TO in Unity 5 0 Answers
Text has stopped calculating its size in 5.2 0 Answers
Set Native Size in UI 1 Answer
Resolution settings not working in build mode, but working perfectly in editor 0 Answers
How to attach a (that world type) canvas to a moving player? 0 Answers