using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class TestDrag : MonoBehaviour
{
float mouseX;
float mouseY;
public void Update()
{
mouseX = Input.GetAxis("Mouse X");
mouseY = Input.GetAxis("Mouse Y");
//用获取的绝对值去比较
if (Mathf.Abs ( mouseX)> Mathf.Abs(mouseY))
{
if (Mathf.Abs(mouseX) > 0.03)
{
this.transform.Rotate(Vector3.forward, Time.deltaTime * (mouseX / Mathf.Abs(mouseX)) * 100);
}
}
else if (Mathf.Abs(mouseX) < Mathf.Abs(mouseY))
{
if (Mathf.Abs(mouseY) > 0.03)
{
this.transform.Rotate(Vector3.forward, Time.deltaTime * (mouseY / Mathf.Abs(mouseY)) * 100);
}
}
}
}