Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional XR SDK PreInit #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion com.valve.openvr/Editor/OpenVRSettingsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -76,6 +82,10 @@ public override void OnInspectorGUI()
{
m_MirrorViewMode = serializedObject.FindProperty(kMirrorViewModeKey);
}
if (m_PreInit == null)
{
m_PreInit = serializedObject.FindProperty(kPreInit);
}

serializedObject.Update();

Expand All @@ -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();

Expand Down
11 changes: 10 additions & 1 deletion com.valve.openvr/Runtime/OpenVRLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions com.valve.openvr/Runtime/OpenVRSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down