在Unity调试触摸事件必须在真机,很不方便有这个方法就方便多了
using UnityEngine;
using System.Collections;
public class JFTouch {
public static bool TouchBegin()
{
if(Input.GetMouseButtonDown(0))
{
return true;
}
else if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
return true;
}
return false;
}
public static bool TouchEnd()
{
if(Input.GetMouseButtonUp(0))
{
return true;
}
else if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
return true;
}
return false;
}
public static bool TouchIng()
{
if(Input.GetMouseButton(0))
{
return true;
}
else if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
return true;
}
return false;
}
}