Vector3 mousePos = Input.mousePosition;
Vector2 dir = mousePos - transform.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
angle = (angle <= 0) ? (360 + angle) : angle;
Quaternion r = Quaternion.AngleAxis(angle, Vector3.forward);
transform.rotation = r;
angle = ((angle >= 315) ? (angle - 360) : angle) + 45;
直接将这个代码挂在要旋转的图片上放在Updata里面就可以执行