自己建个Cube后将下面的脚本挂上去,运行,按键盘R键或T键看效果。
using UnityEngine;
using System.Collections;
public class Hello : MonoBehaviour {
float rotate = 30.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.R)) {
transform.RotateAround (transform.position, Vector3.right, rotate);
}
if (Input.GetKey (KeyCode.T)) {
transform.RotateAround (transform.position, Vector3.right, -rotate);
}
}
}