- Home /
Question by
Bobby1990 · Apr 22, 2015 at 09:29 PM ·
c#touchmultitouch
multi-touch problem in the " Space Shooter to Mobile" tutorial
Hi, i was following this: link text
tutorial and everything works fine except the multi-touch parts. i have two button that are actually two different images in the canvas but when i use one i can't use the other touch button. :(
here is the code:
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections;
public class SimpleTouchShoot : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
private bool touched;
private int pointerID;
private bool canFire;
void Awake()
{
touched = false;
canFire = false;
}
public void OnPointerDown (PointerEventData data)
{
if(!touched)
{
touched = true;
pointerID = data.pointerId;
canFire = true;
}
}
public void OnPointerUp (PointerEventData data)
{
if(data.pointerId == pointerID)
{
touched = false;
canFire = false;
}
}
public bool CanFire ()
{
return canFire;
}
}
i'm using unity 4.6 by the way.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613193817im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem with multi touch[solved] 0 Answers
Distribute terrain in zones 3 Answers
MultiTouch Help(C#) 1 Answer
Android 2D multitouch joystick + buttons 0 Answers