|
InputManager.ControllerState.IsTouching 判断是否是在触摸
InputManager.ControllerState.TouchPosition 判断触摸板位置
using MIVR;using UnityEngine;using UnityEngine.UI;public class Player : MonoBehaviour { public GameObject cube; void Start () { } void Update() { print("MIVR"+ InputManager.ControllerState.TouchPosition); if (InputManager.ControllerState.IsTouching) { //上 if (InputManager.ControllerState.TouchPosition.y <= 0.25 && InputManager.ControllerState.TouchPosition.y > 0) { cube.transform.Translate(Vector3.forward * Time.deltaTime); } //下 if (InputManager.ControllerState.TouchPosition.y >= 0.75) { cube.transform.Translate(Vector3.back * Time.deltaTime); } //左 if (InputManager.ControllerState.TouchPosition.x <= 0.25 && InputManager.ControllerState.TouchPosition.x > 0) { cube.transform.Rotate(0, -45 * Time.deltaTime, 0); } //右 if (InputManager.ControllerState.TouchPosition.x >= 0.75) { cube.transform.Rotate(0, 45 * Time.deltaTime, 0); } } }} |
|