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

unity js操作模型 加音频 需修改

2015-03-19 23:45 260 查看
#pragma strict

function Start () {

}

var run =0;

var isOn:boolean;

var RotateSpeed = 1000;

var aaudio:AudioSource;

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));

aaudio=this.GetComponent(AudioSource);

aaudio.Play();

}

}

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)

{

//其他按钮的代码

}

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