So I’m making a VR game using this tutorial
and the variable isn’t showing in the inspector and I can’t figure it out!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class HandPresence : MonoBehaviour
{
public List<GameObject> controllerPrefabs;
private InputDevice targetDevice;
// Start is called before the first frame update
void Start()
{
List<InputDevice> devices = new List<InputDevice>();
InputDeviceCharacteristics rightControllerCharacteristics = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;
InputDevices.GetDevicesWithCharacteristics(rightControllerCharacteristics, devices);
foreach (var item in devices)
{
Debug.Log(item.name + item.characteristics);
}
if(devices.Count > 0)
{
targetDevice = devices[0];
}
}
// Update is called once per frame
void Update()
{
if (targetDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool primaryButtonValue) && primaryButtonValue)
Debug.Log("Pressing Primary Button");
if (targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue) && triggerValue > 0.1f)
Debug.Log("Trigger pressed " + triggerValue);
if (targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxisValue) && primaryButtonValue != Vector2.zero)
Debug.Log("Primary Touchpad" + primary2DAxisValue);
}
}