using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class zuoyoiu : MonoBehaviour
{
private Vector2 first = Vector2.zero;
private Vector2 second = Vector2.zero;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
//記錄鼠標按下的位置
first = Input.mousePosition;
}
if (Input.GetMouseButtonUp(0))
{
//記錄鼠標拖動的位置
second = Input.mousePosition;
if (second.x < first.x)
{
//拖動的位置的x座標比按下的位置的x座標小時,響應向左事件
print("left");
}
if (second.x > first.x)
{
//拖動的位置的x座標比按下的位置的x座標大時,響應向右事件
print("right");
}
first = second;
}
}
}