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

js操作unity模型旋转

2015-05-15 00:00 441 查看
#pragma strict

function Start () {

}

var run =0;
var isOn:boolean;
var RotateSpeed = 1000;

function Update () {
if (Input.touchCount == 1)
{
if(isOn == true){
isOn=false;
} else{
isOn=true;
}
//One finger touch does orbit
//
// touch = Input.GetTouch(0);
//
// x += touch.deltaPosition.x * xSpeed * 0.02;
//
// y -= touch.deltaPosition.y * ySpeed * 0.02;

}
if(isOn == true){
transform.Rotate(Vector3.up * Time.deltaTime * (-RotateSpeed));
}

}

function OnGUI()
{
//开关按钮,使用了三目运算符来控制显示on或者off
if(GUI.Button(Rect(0,0,200,40),(isOn)?"on":"off"))
{
//用三目运算符控制布尔类型开关变量值
if(isOn==true){
isOn=false;
}else{
isOn=true;
}

}

if(isOn)
{
//其他按钮的代码
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: