[DesktopVRSwitch] Prevent SteamVR_Behaviour from closing game.

Was going to use my own event and switch before quit, but SteamVR_Behaviour was the one doing it the entire time. Very convenient for me.
This commit is contained in:
NotAKidoS 2023-06-20 15:15:42 -05:00
parent 52d4ef3279
commit 337134d2b5
3 changed files with 34 additions and 7 deletions

View file

@ -8,6 +8,7 @@ using HarmonyLib;
using NAK.DesktopVRSwitch.Patches;
using NAK.DesktopVRSwitch.VRModeTrackers;
using UnityEngine;
using Valve.VR;
namespace NAK.DesktopVRSwitch.HarmonyPatches;
@ -110,4 +111,21 @@ class CohtmlUISystemPatches
// dont
return false;
}
}
class SteamVRBehaviourPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamVR_Behaviour), nameof(SteamVR_Behaviour.OnQuit))]
static bool Prefix_SteamVR_Behaviour_OnQuit()
{
if (DesktopVRSwitch.EntrySwitchToDesktopOnExit.Value)
{
// If we don't switch fast enough, SteamVR will force close.
// World Transition might cause issues. Might need to override.
VRModeSwitchManager.Instance?.AttemptSwitch();
return false;
}
return true;
}
}