【发布时间】:2015-06-30 19:19:36
【问题描述】:
除了多点触控部分外,教程和一切都很好。我有两个按钮,实际上是画布上的两个不同图像,但是当我使用一个时,我不能使用另一个触摸按钮。我的每个按钮都有这个脚本。
代码如下:
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;
}
}
Unity 的版本是 4.6。
【问题讨论】:
标签: c# unity3d touch multi-touch