-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SteamVR not behaving properly when recentering is allowed
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using HarmonyLib; | ||
using UnityEngine.XR.OpenXR; | ||
|
||
namespace SiraUtil.Tweaks | ||
{ | ||
/// <summary> | ||
/// This patch fixes an issue with SteamVR where Unity will decide to not use SteamVR's room center | ||
/// and instead try to invent its own origin, often resulting in the headset being under the floor. | ||
/// This tends to happen when using FPFCToggle. | ||
/// </summary> | ||
/// <remarks> | ||
/// This post explains the various possible OpenXR tracking spaces: <see href="https://discussions.unity.com/t/how-to-recenter-in-openxr/935209/9"/> | ||
/// </remarks> | ||
[HarmonyPatch(typeof(OpenXRLoaderBase), nameof(OpenXRLoaderBase.Initialize))] | ||
internal static class DisableOpenXRRecentering | ||
{ | ||
private static void Postfix(ref bool __result) | ||
{ | ||
if (__result && OpenXRRuntime.name == "SteamVR/OpenXR") | ||
{ | ||
Plugin.Log.Info("Disabling recentering"); | ||
OpenXRSettings.SetAllowRecentering(false, 0); | ||
} | ||
} | ||
} | ||
} |