if (Input.GetMouseButton(0))
{
Vector3 pos = transform.rectTransform().anchoredPosition;
Vector3 targetPos = Input.mousePosition - new Vector3(Screen.width / 2, Screen.height / 2, 0);
Vector3 to = targetPos - pos;
float z;
if (targetPos.x > pos.x)
{
z = -Vector3.Angle(Vector3.up, to);
}
else
{
z = Vector3.Angle(Vector3.up, to);
}
transform.localRotation = Quaternion.Euler(0, 0, z);
}
2DUI随鼠标改变Z轴角度
最新推荐文章于 2024-05-26 23:32:44 发布