void MobileInput()
{
if(Input.touchCount <= 0)
return;
//1个手指触摸屏幕
if (Input.touchCount == 1)
{
if(Input.touches[0].phase == TouchPhase.Began)
{
//记录手指触屏的位置
m_screenpos= Input.touches[0].position;
}
// 手指移动
else if(Input.touches[0].phase == TouchPhase.Moved)
{
//移动摄像机
Camera.main.transform.Translate(newVector3(Input.touches[0].deltaPosition.x * Time.deltaTime,Input.touches[0].deltaPosition.y * Time.deltaTime, 0));
}
//手指离开屏幕判断移动方向
if(Input.touches[0].phase == TouchPhase.Ended &&
Input.touches[0].phase!= TouchPhase.Canceled)
{
Vector2pos = Input.touches[0].position;
//手指水平移动
if(Mathf.Abs(m_screenpos.x - pos.x) > Mathf.Abs(m_screenpos.y - pos.y))
{
if(m_screenpos.x > pos.x){
//手指向左划动
}
else{
//手指向右划动
}
}
else //手指垂直移动
{
if(m_screenpos.y > pos.y){
//手指向下划动
}
else{
//手指向上划动
}
}
}