当前位置: 代码迷 >> Android >> Android Unity3d 腾挪脚本
  详细解决方案

Android Unity3d 腾挪脚本

热度:600   发布时间:2016-05-01 15:14:46.0
Android Unity3d 移动脚本
//model speed
var TranslateSpeed = 20;
//rotate speed
var RotateSpeed = 1000;
//draw gui
function OnGUI() 
{
//gui background
GUI.backgroundColor = Color.red;

//model to left 
if(GUI.Button(Rect(10,10,70,30), "left")){
transform.Rotate(Vector3.up *Time.deltaTime * -RotateSpeed);
}

if(GUI.Button(Rect(90,10,70,30), "font")){
transform.Translate(Vector3.forward * Time.deltaTime 
*TranslateSpeed);  

}

if(GUI.Button(Rect(170,10,70,30), "right")){
transform.Rotate(Vector3.up *Time.deltaTime * RotateSpeed);
}

if(GUI.Button(Rect(90,50,70,30), "back")){
transform.Translate(Vector3.forward * Time.deltaTime * -
TranslateSpeed);  
}

if(GUI.Button(Rect(10,50,70,30), "left")){
transform.Translate(Vector3.right * Time.deltaTime *-
TranslateSpeed);  
}

if(GUI.Button(Rect(170,50,70,30), "right")){
transform.Translate(Vector3.right * Time.deltaTime * 
TranslateSpeed); 
}

//info
GUI.Label(Rect(250, 10,200,30),"position" +transform.position);  
 
GUI.Label(Rect(250, 50,200,30),"rotate position" +transform.rotation);   
}
  相关解决方案