ValveSoftware / steamvr_unity_plugin

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

Actions with defaults assigned can change unexpectedly #1026

Open ZnelArts opened 2 years ago

ZnelArts commented 2 years ago

Why the assigned SteamVR actions are being changed by themselves when I load a prefab that has some interactables? See this video:

steamvrissue

Observe how the actions just change, the loaded prefab has no logic to change them, it just has a bunch of interactables.

[EDIT] Doing some more testing it doesn't require to drag the prefab to the scene, the actions change by just selecting the prefab in the Project Tab.

I have been on Unity 2020.3.27 for some time but this started to happen recently so is not related to the Unity version. The only thing that changed recently is the SteamVR client which was updated to 1.21.12 recently.

Additionally every time this happens in the editor the file Open VR Settings.asset gets modified but I didnt change anything on it.

Another note is that this happens right after I get the error NullReferenceException: Object reference not set to an instance of an object Valve.VR.SteamVR_Action`2[SourceMap,SourceElement].get_Item (Valve.VR.SteamVR_Input_Sources inputSource) (at Assets/Imported/SteamVR/Input/SteamVR_Action.cs:44) It seems sourceMap is null for some reason.

This issue seems very similar to https://github.com/ValveSoftware/steamvr_unity_plugin/issues/616

Im using the SteamVR Unity Plugin - v2.7.3 (sdk 1.14.15)

Thanks for any help.

ZnelArts commented 2 years ago

Found what is causing the actions to change even when selecting the prefab on the editor.

As mentioned on the other issue, using defaults for actions will break SteamVR and trigger this bug. I had code like this:

public class ZNEVRInteractor : MonoBehaviour {

    [SerializeField] private SteamVR_Action_Boolean _triggerInput = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("ACTION");
    [SerializeField] private SteamVR_Action_Single _triggerPressure = SteamVR_Input.GetAction<SteamVR_Action_Single>("TriggerPressure");
    [SerializeField] private SteamVR_Action_Boolean _gripInput = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("GrabGrip");

Changed it to:

public class ZNEVRInteractor : MonoBehaviour {

    [SerializeField] private SteamVR_Action_Boolean _triggerInput;
    [SerializeField] private SteamVR_Action_Single _triggerPressure;
    [SerializeField] private SteamVR_Action_Boolean _gripInput;

And that stops the issue from happening.

I hope Keith can take a look at this bug and find a solution for it.