您的位置:首页 > 移动开发 > Unity3D

Unity3D实现点击物体旋转

2013-01-06 20:38 531 查看
using UnityEngine;
using System.Collections;

public class roated : MonoBehaviour {
private bool roate;
private float RoatedSpeed = 1000.0F;
void Start () {
roate = false;
}

// Update is called once per frame
void Update () {

if(Input.GetMouseButton(0))
{
float y = 0;

y = Input.GetAxis("Mouse X")*RoatedSpeed*Time.deltaTime;
if(roate)
{
gameObject.transform.Rotate(new Vector3(0,y,0));

}

}

}
void OnMouseDown()
{

roate =true;
Debug.Log("collider");
}
void OnMouseUp()
{
roate = false;
Debug.Log("Out of collider");
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: