ValveSoftware / steamvr_unity_plugin

SteamVR Unity Plugin - Documentation at: https://valvesoftware.github.io/steamvr_unity_plugin/
BSD 3-Clause "New" or "Revised" License
1.02k stars 255 forks source link

NullReferenceException at Assets/SteamVR/Input/SteamVR_Behaviour_Pose.cs:105 running Interactions_Example scene #148

Closed tonygod closed 5 years ago

tonygod commented 5 years ago

When running the Interactions_Example scene with HTC Vive and Vive controllers, the controllers are not visible and the above error repeats.

NullReferenceException: Object reference not set to an instance of an object Valve.VR.SteamVR_Behaviour_Pose.OnEnable () (at Assets/SteamVR/Input/SteamVR_Behaviour_Pose.cs:105)

SteamVR Plugin: 2.0.1 Unity: 2017.4.12f1 OS: Windows 10 64-bit

zite commented 5 years ago

Hello @tonygod, did you save and generate actions through the SteamVR Input window?

ColdFlameStudios commented 5 years ago

After about an hour of testing with my own issue, I believe I have found the solution. When editing the SteamVR input files, did you perhaps edit or delete the default action set? I can only see and interact with the controllers when my input set includes at least one "Pose" input action for each hand, assigned to their proper locations in LeftHand/RightHand -> Steam VR_Behaviour_Pose Component -> Pose Action field, so ensure that you have that assigned as well if you haven't edited the default action set.

I had found that the Input Binding menu wouldn't show my custom action set for binding, so I edited the default set, not thinking it would break the interaction system. (It would be great to have a reset button on the SteamVR Input window if possible, as well as warnings when you haven't assigned a pose to each hand? This may also apply to glove skeletons?).

Hope this helps.

tonygod commented 5 years ago

@pclevine Thanks for the help. I do remember changing the default action set, but not deleting it.

After a while, I rebuilt and saved the input bindings and it started working properly.

dpggit commented 5 years ago

I have the same error, i click save and generate after binding but the process never ends using Unity 2018.2, just stays there for more than an hour never finishing, when i clicked cancel i get this error when i press play in the interactive scene included in steamvr folder

ColdFlameStudios commented 5 years ago

@dpggit My save and generate on a new project only seems to work after I've tried to press play at least once and been redirected, and then attempted to save and generate again after cancelling the first attempt.

I haven't tried a new project since I got this working the first time, so if that doesn't work I'll see if I can replicate the problem with you to help.

dpggit commented 5 years ago

Click and generate gave me the error NullReferenceException: Object reference not set to an instance of an object Valve.VR.SteamVR_Input_Generator.AssignDefaultsInPrefabs () (at Assets/SteamVR/Input/Editor/SteamVR_Input_Generator.cs:280) which refers to MonoBehaviour[] behaviours = prefab.GetComponentsInChildren(true); so seems the prefab is null, the previous line is GameObject prefab = AssetDatabase.LoadAssetAtPath(prefabPath); so LoadAssetAtPath is not having the right path probably, i just changed the like to if(prefab!=null) MonoBehaviour[] behaviours = prefab.GetComponentsInChildren(true); and it worked

rocky1138 commented 4 years ago

To get around the lack of a "reset default bindings" feature, I keep a fresh Unity project available on my desktop with nothing installed other than SteamVR. You can get the bindings either from the UI in there or through the actions.json file in the fresh project.

MageApoorv commented 4 years ago

Hi , I had a similar problem the hands were visible but as i interacted with buttons etc the errors showed up and hands were disappearing as i grabbed interactable but other members of the project weren't facing the issue where the pose component in the object which needs to be grabbed was empty (number of poses was 0), turn out it was a collab issue. I just asked them to send me a zip of the project(asset folder) and replaced it with my project files and everything was working fine.

runny-yolk commented 4 years ago

I was having a similar issue to this, and figured out how to reset manually - In SteamVR/Input/ExampleJSON, there's the example files. I copy+pasted all of them on top of the files in StreamingAssets/SteamVR, and it fixed the issue. Wiped out all my actions, but I don't have an error getting thrown every frame.

Weirdly, it was throwing in SteamVR_Action_Boolean.cs, but I wasn't even reading one of those (although I did have one set up). The SteamVR Unity plugin was just throwing all on its own.

Another curious thing is that when the issue started, opening the Binding UI would have Gamepad selected as the Current Controller instead of Index.

runny-yolk commented 4 years ago

I figured out my issue, I'm using the glove prefabs that come with the plugin, and they rely on the actions that exist in the default actionset to run - the one I had deleted was GrabPinch. I imagine the above error was caused by deleting Pose. So I guess, be careful messing with those Actionsets, but also, would be nice if these errors were handled a little more gracefully.

aprithul commented 4 years ago

I figured out my issue, I'm using the glove prefabs that come with the plugin, and they rely on the actions that exist in the default actionset to run - the one I had deleted was GrabPinch. I imagine the above error was caused by deleting Pose. So I guess, be careful messing with those Actionsets, but also, would be nice if these errors were handled a little more gracefully.

Exactly same issue here!