using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class RotatedObject : MonoBehaviour
{
//观察旋转的相机
public Camera _camera;
//"需要旋转的物体"
public Transform traget;
bool IsRotated = false;
void Update()
{
if (Input.GetMouseButtonDown (0))
{
IsRotated = true ;
}
if (Input.GetMouseButtonUp (0))
{
IsRotated = false ;
}
if (IsRotated ==true )
{
//获取鼠标轴向
float x = Input.GetAxis("Mouse X");
float y = Input.GetAxis("Mouse Y");
traget.transform.Rotate(_camera.transform.up * x * -5 + _camera.transform.right * y * 5, Space.World);
}
}
}