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

How to properly create a hybrid app with SteamVR and the new XR Plug-in? #954

Open BarboraAtVResearch opened 3 years ago

BarboraAtVResearch commented 3 years ago

Hi, we created a hybrid app using Unity documentation, but we experience a random and quite frequent error of VR controllers not loading correctly. This is the result we get in approx 1/3 of attempts to switch to VR: kostnataRuka I am including the player log as well: Player.log

We are on Unity 2019.4.25f1, SteamVR Unity Plugin - v2.7.2 (sdk 1.14.15), and XR Plugin Management v 3.2.17. Any help would be greatly appreciated. Thanks!

BarboraAtVResearch commented 3 years ago

I forgot to mention, in this case, controller input does not work as well, along with many aspects of the game, like logging, interactions, etc... It is also possible that it is caused by the parameter "range of motion" on a VR hand prefab. We have "with controller" selected.

BarboraAtVResearch commented 3 years ago

Just for clarification, since this is already in the documentation. This is the code we use for switching between 2d and VR. Of course, we call the enumerator as a coroutine: StartCoroutine(StartXRCoroutine()) :)

public IEnumerator StartXRCoroutine()
    {
        Debug.Log("Initializing XR...");
        yield return XRGeneralSettings.Instance.Manager.InitializeLoader();

        if (XRGeneralSettings.Instance.Manager.activeLoader == null)
        {
            Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
        }
        else
        {
            Debug.Log("Starting XR...");
            XRGeneralSettings.Instance.Manager.StartSubsystems();
        }
    }

    void StopXR()
    {
        Debug.Log("Stopping XR...");

        XRGeneralSettings.Instance.Manager.StopSubsystems();
        XRGeneralSettings.Instance.Manager.DeinitializeLoader();
        Debug.Log("XR stopped completely.");
    }