代码改变世界

Rotation of the Cube

2016-10-19 14:42  刘杰0913  阅读(184)  评论(0)    收藏  举报
using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

    // Use this for initialization
    void Start () {
    
    }
    
    // update方法  程序每一帧都会调用该方法,1秒默认30帧 
    void Update () {

        //实现的效果,按键盘上的上下左右键可以翻看模型的各个面[模型旋转]

        if(Input.GetKey(KeyCode.UpArrow)){
            transform.Rotate(Vector3.right*Time.deltaTime*10);
        }

        if(Input.GetKey(KeyCode.DownArrow)){
            transform.Rotate(Vector3.left*Time.deltaTime*10);
        }
        
        if(Input.GetKey(KeyCode.LeftArrow)){
            transform.Rotate(Vector3.up*Time.deltaTime*10);
        }
        
        if(Input.GetKey(KeyCode.RightArrow)){
            transform.Rotate(Vector3.down*Time.deltaTime*10);
        }
    }

}