EDIT: The reason why it wasn’t working was because in the script for getting inputs it tries to get the value of “Swap Controls” but in the build for the quest there was no save file for that, so it would get a null reference error.
Here’s a really weird problem. I’m making a VR game for the quest 2, and when I test it on my computer everything works but when I build it and upload it to my quest 2 and test it there, it doesn’t detect any input from my controllers. I’m certain this is a problem with getting the inputs and not the scripts using the inputs because the code for the tutorial is this
private void Update()
{
if ( done )
{
ES3.Save("Finished Tutorial", true);
return;
}
if ( index == 0 && Inputs.leftTrigger > 0.8f || index == 0 && Inputs.rightTrigger > 0.8f )
{
index++;
}
if ( index == 1 && Inputs.aButtonPressed )
{
index++;
}
if ( index == 2 && Inputs.bButtonPressed )
{
index++;
}
if ( index == 3 && Inputs.bButtonPressed && !jump.isGrounded )
{
index++;
swordCrate.SetActive(true);
}
if ( index == 4 && Inputs.playerInteracted )
{
index++;
}
if ( index == 5 )
{
if ( Inputs.leftGrip > 0.8f )
{
index++;
}
else if ( Inputs.rightGrip > 0.8f )
{
index++;
}
}
if ( index > 0 )
{
texts[index - 1].SetActive(false);
}
texts[index].SetActive(true);
if ( index == 6 )
{
StartCoroutine(End());
}
}
I don’t see any way for this to go wrong in the build.
Also, previous builds worked completely fine. This error only started happening after I made a new scene for a 3rd map in the game. I can’t remember changing anything else.
Here’s the code for getting the inputs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
using UnityEngine.XR.Interaction.Toolkit;
[System.Serializable]
public class GetInputs : MonoBehaviour
{
public InputDeviceCharacteristics controller;
public bool isLeftController;
public XRInteractorLineVisual xrRay;
private InputDevice targetDevice;
private bool UISelected;
private void Start()
{
GetDevice();
}
private void Update()
{
if ( xrRay.reticle.activeInHierarchy )
{
Inputs.leftTrigger = 0;
Inputs.rightTrigger = 0;
UISelected = true;
}
else
{
UISelected = false;
}
if ( !targetDevice.isValid )
{
GetDevice();
return;
}
if ( targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float t) )
{
if ( UISelected )
{
return;
}
if ( isLeftController )
{
if ( ES3.Load<bool>("Swap Controls") )
{
Inputs.rightTrigger = t;
}
else
{
Inputs.leftTrigger = t;
}
}
else
{
if ( ES3.Load<bool>("Swap Controls") )
{
Inputs.leftTrigger = t;
}
else
{
Inputs.rightTrigger = t;
}
}
}
if ( targetDevice.TryGetFeatureValue(CommonUsages.grip, out float g) )
{
if ( isLeftController )
{
if ( ES3.Load<bool>("Swap Controls") )
{
Inputs.rightGrip = g;
}
else
{
Inputs.leftGrip = g;
}
}
else
{
if ( ES3.Load<bool>("Swap Controls") )
{
Inputs.leftGrip = g;
}
else
{
Inputs.rightGrip = g;
}
}
}
if ( targetDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool b) )
{
if ( isLeftController )
{
Inputs.xButtonPressed = b;
}
else
{
Inputs.aButtonPressed = b;
}
}
if ( targetDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out bool n) )
{
if ( isLeftController )
{
Inputs.yButtonPressed = n;
}
else
{
Inputs.bButtonPressed = n;
}
}
if ( targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxisClick, out bool a) )
{
if ( isLeftController )
{
Inputs.leftThumbstickPressed = a;
}
else
{
Inputs.rightThumbstickPressed = a;
}
}
if ( targetDevice.TryGetFeatureValue(CommonUsages.menuButton, out bool m) )
{
if ( isLeftController )
{
Inputs.menuButtonPressed = m;
}
}
}
void GetDevice()
{
List<InputDevice> devices = new List<InputDevice>();
InputDevices.GetDevicesWithCharacteristics(controller, devices);
if ( devices.Count > 0 )
{
targetDevice = devices[0];
}
}
}