void OnEnable(){
EasyJoystick.On_JoystickMove += OnJoystickMove;//添加委托
EasyJoystick.On_JoystickMoveEnd += OnJoystickMoveEnd;
}
void OnJoystickMove(MovingJoystick joy){
// print ("Move");
if (joy.joystickName == "Myjoystick") {
float joyPosX = joy.joystickAxis.x;
float joyPosY = joy.joystickAxis.y;
if (joyPosY!=0||joyPosX!=0) {
transform.LookAt (new Vector3(this.transform.position.x+joyPosX,
this.transform.position.y,this.transform.position.z+joyPosY));//设置摄像机跟随使物体始终正面朝向
transform.Translate (Vector3.forward*Time.deltaTime);
}
}
}
void OnJoystickMoveEnd(MovingJoystick joy){
//print ("End");
}
Unity触摸操作
最新推荐文章于 2023-12-17 23:03:07 发布