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

Fix Unity crash on "Open binding UI" when using as package #491

Closed
Closed
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
20 changes: 13 additions & 7 deletions Assets/SteamVR/Scripts/SteamVR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,21 @@ private static void IdentifyEditorApplication(bool showLogs = true)
}

int processId = System.Diagnostics.Process.GetCurrentProcess().Id;
EVRApplicationError applicationIdentifyErr = OpenVR.Applications.IdentifyApplication((uint)processId, SteamVR_Settings.instance.editorAppKey);

if (applicationIdentifyErr != EVRApplicationError.None)
Debug.LogError("<b>[SteamVR]</b> Error identifying application: " + applicationIdentifyErr.ToString());
else
if (!string.IsNullOrEmpty(SteamVR_Settings.instance.editorAppKey))
{
if (showLogs)
Debug.Log(string.Format("<b>[SteamVR]</b> Successfully identified process as editor project to SteamVR ({0})", SteamVR_Settings.instance.editorAppKey));
}
EVRApplicationError applicationIdentifyErr = OpenVR.Applications.IdentifyApplication((uint)processId, SteamVR_Settings.instance.editorAppKey);

if (applicationIdentifyErr != EVRApplicationError.None)
Debug.LogError("<b>[SteamVR]</b> Error identifying application: " + applicationIdentifyErr.ToString());
else
{
if (showLogs)
Debug.Log(string.Format("<b>[SteamVR]</b> Successfully identified process as editor project to SteamVR ({0})", SteamVR_Settings.instance.editorAppKey));
}
}
else
Debug.LogError("<b>[SteamVR]</b> SteamVR_Settings.instance.editorAppKey is NULL, cannot identify application!");
}

#region Event callbacks
Expand Down
4 changes: 4 additions & 0 deletions Assets/SteamVR/Scripts/SteamVR_Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ private static void LoadInstance()

#if UNITY_EDITOR
string folderPath = SteamVR.GetResourcesFolderPath(true);
if (!System.IO.Directory.Exists(folderPath)) {
Debug.LogWarning($"<b>[SteamVR]</b> Path '{folderPath}' did not exist; creating ...");
System.IO.Directory.CreateDirectory(folderPath);
}
string assetPath = System.IO.Path.Combine(folderPath, "SteamVR_Settings.asset");

UnityEditor.AssetDatabase.CreateAsset(_instance, assetPath);
Expand Down