一:滑动屏幕在固定轴上移动物体
using UnityEngine;
public class Test : MonoBehaviour
{
public float speed; //速度
//判断手势
private void JudgeGesture()
{
if (Input.touchCount == 1)
{
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved)
{
Vector2 touchDeltaPosition = touch.deltaPosition;
transform.Translate(touchDeltaPosition.x * speed, 0, 0);
}
}
}
}
二:点击屏幕
using UnityEngine;
public class Test : MonoBehaviour
{
//判断手势
private void JudgeGesture()
{
//单击
if (Input.touchCount == 1)
{
Touch touch =