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

My unity game is frozen when returning from from Steam system menu #775

Closed alexeystrakh closed 3 years ago

alexeystrakh commented 4 years ago

In my Unity game where I integrated SteamVR Plugin SDK, once I activate a game menu and trying to return back, the game is frozen as if Time.timeScale = 0.

I found a similar issue but it doesn't really have a solution. I have also tried to disable the following settings with no luck:

SteamVR.settings.pauseGameWhenDashboardVisible = false;

Do I need to manually handle return from menu (the same is true for removing and putting back the headset) and unfreeze the game somehow?

alexeystrakh commented 4 years ago

It was an issue in SteamVR_Render component (SteamVR Plugin SDK), which wasn't reporting OnInputFocus when the focus is back. So it was freezing the input on focus lost and didn't call the OnInputFocus to restore the game properly.

So I have set the following settings to false

SteamVR.settings.pauseGameWhenDashboardVisible = false

and update the SDK method to add its non-working logic inside that if:

private void OnInputFocus(bool hasFocus)
        {
            if (SteamVR.active == false)
                return;

            if (hasFocus)
            {
                if (SteamVR.settings.pauseGameWhenDashboardVisible)
                {
                    Time.timeScale = timeScale;
                    SteamVR_Camera.sceneResolutionScale = sceneResolutionScale;
                }
            }
            else
            {
                if (SteamVR.settings.pauseGameWhenDashboardVisible)
                {
                    timeScale = Time.timeScale;
                    Time.timeScale = 0.0f;
                    sceneResolutionScale = SteamVR_Camera.sceneResolutionScale;
                    SteamVR_Camera.sceneResolutionScale = 0.5f;
                }
            }
        }