Hi, while developing for Oculus Quest I am receiving the error
“Library\PackageCache\io.extendreality.tilia.input.unityinputmanager@1.3.5\Runtime\SharedResources\Scripts\UnityInputManagerAxis1DAction.cs(30,21): error CS0103: The name ‘OVRInput’ does not exist in the current context”
when using the following code.
My Setting
Since I can’t get Inputs to work via Tilia, I wanted to simply use the Oculus Library - but though I have the Oculus Loader from “XR Plugin-Management” and the “Oculus Integration”-Package integrated, and the script is in a sub-directory from “assets”, the script “OVRInput.cs” doesn’t seem to be compiled first, so that I can’t access the class “OVRInput” from Tilia to change the Input-Script from Tilia to receive the Input via OVRInput.
My goal is simply to be able to be able to use button inputs in scripts.
The Script is located in “Packages/Tilia Input UnityInputManager/Runtime/SharedRessources/Scripts” Line 30 produces the compiler error.
Not working Code
namespace Tilia.Input.UnityInputManager
{
using Malimbe.PropertySerializationAttribute;
using Malimbe.XmlDocumentationAttribute;
using UnityEngine;
using Zinnia.Action;
using Zinnia.Process;
/// <summary>
/// Listens for the specified axis and emits the appropriate action.
/// </summary>
public class UnityInputManagerAxis1DAction : FloatAction, IProcessable
{
/// <summary>
/// The named axis to listen for state changes on.
/// </summary>
[Serialized]
[field: DocumentedByXml]
public string AxisName { get; set; }
/// <summary>
/// Multiplies the axis value.
/// </summary>
[Serialized]
[field: DocumentedByXml]
public float Multiplier { get; set; } = 1f;
/// <inheritdoc />
public void Process()
{
Receive(OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger) * Multiplier);
}
}
}
This script, located in “assets/MyAssets/Scripts”: Line 34 works.
Working Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class VRUiInteractor: MonoBehaviour
{
private Button selectedButton = null;
public void PressButton()
{
if(selectedButton != null)
{
selectedButton.onClick.Invoke();
}
}
// Start is called before the first frame update
// Update is called once per frame
void Update()
{
RaycastHit hitInfo;
if (Physics.Raycast(transform.position, transform.forward, out hitInfo, 5))
{
// Wenn das getroffene Objekt einen Button besitzt, wähle ihn aus!
Button button = hitInfo.collider.GetComponent<Button>();
if (button != null)
{
button.Select();
selectedButton = button;
}
}
if (OVRInput.GetDown(OVRInput.Button.One))
{
PressButton();
}
}
}
works without problems and can access OVRInput. What is wrong? Namespace problem? “using OVRInput” doesn’t help. Must the Script be somehow in the assets folder? As I understood this, the OVRPlugin should make all OVR scripts being available for all other scripts within the project.