Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.XR;
- public class Controller : MonoBehaviour
- {
- public float speed = 1;
- [Tooltip("Testo da cambiare")]
- public Text textObject;
- // Start is called before the first frame update
- void Start()
- {
- }
- string GetButtons()
- {
- // get the device we want to check
- List<InputDevice> devices = null;
- InputDevices.GetDevicesWithRole(InputDeviceRole.RightHanded, devices);
- // go through our devices
- var list = new List<(string, InputFeatureUsage<bool>)> {
- ("triggerButton",CommonUsages.triggerButton),
- ("gripButton",CommonUsages.gripButton) ,
- ("thumbrest", CommonUsages.thumbrest) ,
- ("primary2DAxisClick",CommonUsages.primary2DAxisClick) ,
- ("primary2DAxisTouch",CommonUsages.primary2DAxisTouch) ,
- ("menuButton",CommonUsages.menuButton) ,
- ("secondaryButton",CommonUsages.secondaryButton) ,
- ("secondaryTouch",CommonUsages.secondaryTouch) ,
- ("primaryButton",CommonUsages.primaryButton) ,
- ("primaryTouch",CommonUsages.primaryTouch) };
- string ret = "";
- foreach (InputDevice device in devices)
- {
- foreach ((string name, InputFeatureUsage<bool> selectedFeature) in list)
- {
- bool value;
- device.TryGetFeatureValue(selectedFeature, out value);
- ret += "\n" + name + ":" + value;
- }
- }
- return ret;
- }
- // Update is called once per frame
- void Update()
- {
- string buttons = GetButtons();
- textObject.text = buttons;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement