using UnityEngine;
using System.Collections;
/*
* 物体旋转的脚本
* 物体左右旋转()
*/
public class RotateMouse : MonoBehaviour
{
private bool isRotate;
public float RotatedSpeed = 1000.0F;
void Start()
{
isRotate = false;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0))
{
float y = 0;
y = Input.GetAxis("Mouse X") * RotatedSpeed * Time.deltaTime;
if (isRotate)
{
gameObject.transform.Rotate(new Vector3(0, -y, 0));
}
}
}
void OnMouseDown()
{
isRotate = true;
Debug.Log("collider");
}
void OnMouseUp()
{
isRotate = false;
Debug.Log("Out of collider");
}
}
using System.Collections;
/*
* 物体旋转的脚本
* 物体左右旋转()
*/
public class RotateMouse : MonoBehaviour
{
private bool isRotate;
public float RotatedSpeed = 1000.0F;
void Start()
{
isRotate = false;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0))
{
float y = 0;
y = Input.GetAxis("Mouse X") * RotatedSpeed * Time.deltaTime;
if (isRotate)
{
gameObject.transform.Rotate(new Vector3(0, -y, 0));
}
}
}
void OnMouseDown()
{
isRotate = true;
Debug.Log("collider");
}
void OnMouseUp()
{
isRotate = false;
Debug.Log("Out of collider");
}
}