虚拟键盘按钮

1、新建一个GUITexture,重命名为JumpButton
2、给JumpButton选择所需的按钮图片
3、新建如下js脚本,添加给JumpButton

@script RequireComponent( GUITexture ) 
var jumpSpeed:float=3.0;
var controller : CharacterController ;
function Update() 
{ 
for (var i = 0; i < Input.touchCount; i++) 
{ 
var touch = Input.GetTouch(i); 

if(touch.phase == TouchPhase.Stationary && guiTexture.HitTest(touch.position)) //按着按钮不动时 
{ 
//do something... 
} 

else if(touch.phase == TouchPhase.Began && guiTexture.HitTest(touch.position)) //单击按钮时 
{ 
controller.SimpleMove(Vector3.up * jumpSpeed);

} 


} 
}




这是跳跃按钮,呼喊按钮自己仿着做吧

 

你可能感兴趣的:(虚拟键盘按钮)