'OVRInput' could not be found
Please this error is driving me INSANE!! And I can't figure out how does it work. I know there are millions of topics, but there are no explanations and all are different.
This is my case:
Assets/OvrAvatar/Scripts/OvrAvatarLocalDriver.cs(15,36): error CS0246: The type or namespace name `OVRInput' could not be found. Are you missing an assembly reference?
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using Oculus.Avatar;
using UnityEngine.UI;
public class OvrAvatarLocalDriver : OvrAvatarDriver {
private const float mobileBaseHeadHeight = 1.7f;
float voiceAmplitude = 0.0f;
ControllerPose GetControllerPose(OVRInput.Controller controller)
{
ovrAvatarButton buttons = 0;
if (OVRInput.Get(OVRInput.Button.One, controller)) buttons |= ovrAvatarButton.One;
if (OVRInput.Get(OVRInput.Button.Two, controller)) buttons |= ovrAvatarButton.Two;
if (OVRInput.Get(OVRInput.Button.Start, controller)) buttons |= ovrAvatarButton.Three;
if (OVRInput.Get(OVRInput.Button.PrimaryThumbstick, controller)) buttons |= ovrAvatarButton.Joystick;
ovrAvatarTouch touches = 0;
if (OVRInput.Get(OVRInput.Touch.One, controller)) touches |= ovrAvatarTouch.One;
if (OVRInput.Get(OVRInput.Touch.Two, controller)) touches |= ovrAvatarTouch.Two;
if (OVRInput.Get(OVRInput.Touch.PrimaryThumbstick, controller)) touches |= ovrAvatarTouch.Joystick;
if (OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, controller)) touches |= ovrAvatarTouch.ThumbRest;
if (OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger, controller)) touches |= ovrAvatarTouch.Index;
if (!OVRInput.Get(OVRInput.NearTouch.PrimaryIndexTrigger, controller)) touches |= ovrAvatarTouch.Pointing;
if (!OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, controller)) touches |= ovrAvatarTouch.ThumbUp;
return new ControllerPose
{
buttons = buttons,
touches = touches,
joystickPosition = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, controller),
indexTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, controller),
handTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, controller),
isActive = (OVRInput.GetActiveController() & controller) != 0,
};
}
private PoseFrame GetCurrentPose()
{
Vector3 headPos = UnityEngine.VR.InputTracking.GetLocalPosition(UnityEngine.VR.VRNode.CenterEye);
#if UNITY_ANDROID && !UNITY_EDITOR
headPos.y += mobileBaseHeadHeight;
#endif
return new PoseFrame
{
voiceAmplitude = voiceAmplitude,
headPosition = headPos,
headRotation = UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.CenterEye),
handLeftPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch),
handLeftRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch),
handRightPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch),
handRightRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch),
controllerLeftPose = GetControllerPose(OVRInput.Controller.LTouch),
controllerRightPose = GetControllerPose(OVRInput.Controller.RTouch),
};
}
public override void UpdateTransforms(IntPtr sdkAvatar)
{
if (sdkAvatar != IntPtr.Zero)
{
PoseFrame pose = GetCurrentPose();
ovrAvatarTransform bodyTransform = OvrAvatar.CreateOvrAvatarTransform(pose.headPosition, pose.headRotation);
ovrAvatarHandInputState inputStateLeft = OvrAvatar.CreateInputState(OvrAvatar.CreateOvrAvatarTransform(pose.handLeftPosition, pose.handLeftRotation), pose.controllerLeftPose);
ovrAvatarHandInputState inputStateRight = OvrAvatar.CreateInputState(OvrAvatar.CreateOvrAvatarTransform(pose.handRightPosition, pose.handRightRotation), pose.controllerRightPose);
CAPI.ovrAvatarPose_UpdateBody(sdkAvatar, bodyTransform);
CAPI.ovrAvatarPose_UpdateHands(sdkAvatar, inputStateLeft, inputStateRight);
}
}
}
Why?? Please explain the theory behind it! Thanks!
Answer by samra2494 · Feb 07, 2019 at 07:07 AM
Hi, Please download and import this package in your project. all errors will be gone. i have tried this and it works good for me. https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022
This still works for me as of Unity 2019.4.10f1! The other responses from 2017 are obsolete.
Answer by Vicarian · Jul 04, 2017 at 06:30 AM
There isn't a theory. It's Computer Science. You're simply missing a package that exposes the type OVRInput (it's a symbol that gets added to a symbol table for parsing by a compiler, etc.) OVRInput (which you get by downloading the Oculus Unity Runtimes) never got added to the symbol table. Since it's off in the ether somewheres, the C# compiler alerts you that it found an unexpected symbol and throws CS0246. Go hop on Oculus's Dev site and get those sweet, succulent unitypackages.
https://developer.oculus.com/downloads/package/oculus-utilities-for-unity-5/
Answer by DHARMAKAYA · Sep 24, 2017 at 01:16 AM
Considering that the oculus utilities has a bunch of errors, seemingly because facebook has a 3rd world labor sweatshop of 3rd world programmers that facebook hires on the cheap via the horrible h1b visa scam, that answer is relatively useless. I imagine the op CERTAINLY WOULDN'T want to run a while loop without a break statement while executing the trouble shoot.
I have no issues with the Oculus Utilities. I don't quite know what you're even talking about, and sounds as if you're biased against Facebook. There isn't even a while loop in the source the OP posted. If the OP wants OvrAvatar to work, it requires the Oculus Utilities, end of story.
Your answer
