From ba6d963d0e2b4d8ea60396a91c34c410c9fb4f1d Mon Sep 17 00:00:00 2001 From: Verex Date: Fri, 30 Jul 2021 12:21:25 -0400 Subject: [PATCH] XR SDK PreInit is now optional. --- com.valve.openvr/Editor/OpenVRSettingsEditor.cs | 12 +++++++++++- com.valve.openvr/Runtime/OpenVRLoader.cs | 11 ++++++++++- com.valve.openvr/Runtime/OpenVRSettings.cs | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/com.valve.openvr/Editor/OpenVRSettingsEditor.cs b/com.valve.openvr/Editor/OpenVRSettingsEditor.cs index ab84d81..a9805e5 100644 --- a/com.valve.openvr/Editor/OpenVRSettingsEditor.cs +++ b/com.valve.openvr/Editor/OpenVRSettingsEditor.cs @@ -27,6 +27,12 @@ public class OpenVRSettingsEditor : UnityEditor.Editor private SerializedProperty m_MirrorViewMode; + private const string kPreInit = "PreInit"; + + static GUIContent s_PreInit = EditorGUIUtility.TrTextContent("XR SDK PreInit"); + + private SerializedProperty m_PreInit; + public GUIContent WindowsTab; private int tab = 0; @@ -76,6 +82,10 @@ public override void OnInspectorGUI() { m_MirrorViewMode = serializedObject.FindProperty(kMirrorViewModeKey); } + if (m_PreInit == null) + { + m_PreInit = serializedObject.FindProperty(kPreInit); + } serializedObject.Update(); @@ -89,9 +99,9 @@ public override void OnInspectorGUI() if (tab == 0) { EditorGUILayout.PropertyField(m_InitializationType, s_InitializationType); - EditorGUILayout.PropertyField(m_StereoRenderingMode, s_StereoRenderingMode); EditorGUILayout.PropertyField(m_MirrorViewMode, s_MirrorViewMode); + EditorGUILayout.PropertyField(m_PreInit, s_PreInit); } EditorGUILayout.EndVertical(); diff --git a/com.valve.openvr/Runtime/OpenVRLoader.cs b/com.valve.openvr/Runtime/OpenVRLoader.cs index 182d11e..388eb56 100644 --- a/com.valve.openvr/Runtime/OpenVRLoader.cs +++ b/com.valve.openvr/Runtime/OpenVRLoader.cs @@ -443,7 +443,16 @@ public static void TickCallback(int value) #if UNITY_EDITOR public string GetPreInitLibraryName(BuildTarget buildTarget, BuildTargetGroup buildTargetGroup) { - return "XRSDKOpenVR"; + OpenVRSettings settings = OpenVRSettings.GetSettings(); + + // Operate normally if we have PreInit enabled. + if (settings != null && settings.PreInit) + { + return "XRSDKOpenVR"; + } + + // Returning null prevents XRSDKPreInit. + return null; } private static void DisableTickOnReload() diff --git a/com.valve.openvr/Runtime/OpenVRSettings.cs b/com.valve.openvr/Runtime/OpenVRSettings.cs index 32e21f4..3346f5a 100644 --- a/com.valve.openvr/Runtime/OpenVRSettings.cs +++ b/com.valve.openvr/Runtime/OpenVRSettings.cs @@ -59,6 +59,9 @@ public enum MirrorViewModes [SerializeField, Tooltip("Which eye to use when rendering the headset view to the main window (none, left, right, or a composite of both + OpenVR overlays)")] public MirrorViewModes MirrorView = MirrorViewModes.Right; + [SerializeField, Tooltip("Should the library interface with XR SDK PreInit.")] + public bool PreInit = false; + public const string StreamingAssetsFolderName = "SteamVR"; public const string ActionManifestFileName = "legacy_manifest.json"; public static string GetStreamingSteamVRPath(bool create = true)