From c2eb5e6e9c130d641622bfa35437925697279bf5 Mon Sep 17 00:00:00 2001 From: Fairplex Date: Mon, 9 Sep 2024 04:26:27 +0200 Subject: [PATCH] fix: RuntimeLogWatcher path on Linux Listen for client exception should find the correct path on linux --- .../Editor/UdonSharpRuntimeLogWatcher.cs | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Packages/com.vrchat.UdonSharp/Editor/UdonSharpRuntimeLogWatcher.cs b/Packages/com.vrchat.UdonSharp/Editor/UdonSharpRuntimeLogWatcher.cs index 6730d969..a1291949 100644 --- a/Packages/com.vrchat.UdonSharp/Editor/UdonSharpRuntimeLogWatcher.cs +++ b/Packages/com.vrchat.UdonSharp/Editor/UdonSharpRuntimeLogWatcher.cs @@ -55,8 +55,46 @@ private static bool InitializeScriptLookup() AssemblyReloadEvents.beforeAssemblyReload += CleanupLogWatcher; // Now setup the filesystem watcher + string VRCDataPath = null; + #if UNITY_EDITOR_LINUX - string VRCDataPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.local/share/Steam/steamapps/compatdata/438100/pfx/drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat/"; + string vrchatAppId = "438100"; + string steamConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.steam/steam/steamapps/libraryfolders.vdf"; + string steamappsVrchatPath = $"steamapps/compatdata/{vrchatAppId}/pfx/drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat/"; + + if (File.Exists(steamConfigPath)) + { + // Read the entire content of libraryfolders.vdf + var lines = File.ReadAllLines(steamConfigPath); + string currentPath = null; + + foreach (var line in lines) + { + // Match lines with the "path" key to get the library paths + if (line.Contains("\"path\"")) + { + // Extract the path using regex + var match = Regex.Match(line, "\"path\"\\s*\"([^\"]+)\""); + + if (match.Success) + { + currentPath = match.Groups[1].Value; + } + } + + // Check if the line contains the VRChat app ID + if (currentPath != null && line.Contains($"\"{vrchatAppId}\"")) + { + // Construct the VRChat data path from the found library path + string vrchatPath = Path.Combine(currentPath, steamappsVrchatPath); + if (Directory.Exists(vrchatPath)) + { + VRCDataPath = vrchatPath; + break; + } + } + } + } #else // UNITY_EDITOR_WIN || UNITY_EDITOR_MAC string[] splitPath = Application.persistentDataPath.Split('/', '\\'); string VRCDataPath = string.Join("\\", splitPath.Take(splitPath.Length - 2)) + "\\VRChat\\VRChat";