steamvr_unity_plugin: SteamVR_Actions broken after Scene reload
If you use the SteamVR interaction system in Unity and setup default parameters via
SteamVR_Action_Boolean someAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("InteractUI");
the interaction system gets broken if you change the button type in the inspector to something other than the default value and then reload the scene in play mode. The problem persists until you restart Unity.
Use this script to see yourself:
using UnityEngine;
using UnityEngine.SceneManagement;
using Valve.VR;
public class InteractionBug : MonoBehaviour
{
public SteamVR_Action_Boolean button = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("InteractUI");
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
To Reproduce:
- Open a new Unity Project
- Import Steam VR
- Generate the default SteamVR Inputs
- Create a new Scene
- Delete the Main Camera
- Pull in the Player Prefab ( from SteamVR/InteractionSystem/Core/Prefabs )
- Add the provided Script to any GameObject in the scene
- Go to that GameObject and change the Button in the Inspector to something else as InteractUI
- Press play and observe any of the Hand scrips from the Player in scene
- Now press space to reload the scene
- Observe the Player Hands again and note that the Ui Interact Action has changed to whatever you selected in the provided script to at step 8
- The Ui Interact Action is now broken and can’t be changed reversed to the original button and Unity must be restarted in order to do so
Or download this project I set up and just try it out (you can skip step 1 - 8 then) https://github.com/Noblauch/SteamVR_Interaction_Bug
Expected: The SteamVR_Input.GetAction<SteamVR_Action_Boolean>(“InteractUI”) function only gets the defined (bound) button for the specific action and doesn’t have the ability to actually change or destroy something.
It took me 2 days and overall ~19 hours at work to even figure out what the hell is going on. I really hope this gets fixed and some poor soul finds this post, so he doesn’t need to commit -m “suicide”
My question now would still be how to initialize a button for the inspector because this way is breaking the system. However it’s actually exactly done like that in the interaction system example scene.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 4
- Comments: 15
Thanks for the example project and detailed repro steps. I attempted to repro using your project but was unable to. When I reloaded the scene by hitting space bar it didn’t revert the state of the action. I tried this with Unity 2019.2.0f1.
You may be having an issue with multiple player objects in your scene. If you go into the player prefab, SteamVRObjects, then [SteamVR] you’ll see a checkbox for if you want to set the player to DoNotDestroy. Which in this case you probably don’t. Let me know if this helps.