- 最后登录
- 2017-6-30
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 10267
- 纳金币
- 6520
- 精华
- 14
|
var originalPos : Vector3;
private var IsRight;
private var IsLeft;
private var IsUp;
private var IsDown;
function Start()
{
originalPos = transform.position;
}
function Update()
{
if( Input.GetMouseButton(0)&&IsRight )
{
this.transform.Translate(Vector3.right*Time.deltaTime );
}
else if( Input.GetMouseButton(0)&&IsLeft )
{
this.transform.Translate(Vector3.left*Time.deltaTime );
}
else if( Input.GetMouseButton(0)&&IsDown )
{
this.transform.Translate(Vector3.down*Time.deltaTime );
}
else if( Input.GetMouseButton(0)&&IsUp )
{
this.transform.Translate(Vector3.up*Time.deltaTime );
}
else if(Input.GetMouseButtonUp(0))
{
transform.position = originalPos;
}
}
function OnGUI()
{
if (GUI.Button(Rect(15,70,50,30),"Left"))
{
IsRight=!IsRight;
}
if (GUI.Button(Rect(65,70,50,30),"Right"))
{
IsLeft=!IsLeft;
}
if (GUI.Button(Rect(40,100,50,30),"Down"))
{
IsDown=!IsDown;
}
if (GUI.Button(Rect(40,40,50,30),"Up"))
{
IsUp=!IsUp;
}
} |
|