From 096cf3555dec659f763478e64d6623891fc42fa6 Mon Sep 17 00:00:00 2001 From: bd_ Date: Fri, 13 Sep 2024 17:21:29 -0700 Subject: [PATCH] backport: workaround VRCSDK bug https://feedback.vrchat.com/sdk-bug-reports/p/string-conversion-errors-from-runtimeassemblygetcodebase-with-japanese-locale-an --- Editor/HarmonyPatches/PatchLoader.cs | 1 + ...SDKBug_AssemblyGetNameExceptionHandling.cs | 23 +++++++++++++++++++ ...g_AssemblyGetNameExceptionHandling.cs.meta | 3 +++ 3 files changed, 27 insertions(+) create mode 100644 Editor/HarmonyPatches/VRCSDKBug_AssemblyGetNameExceptionHandling.cs create mode 100644 Editor/HarmonyPatches/VRCSDKBug_AssemblyGetNameExceptionHandling.cs.meta diff --git a/Editor/HarmonyPatches/PatchLoader.cs b/Editor/HarmonyPatches/PatchLoader.cs index 092b79a4..7d04a6b5 100644 --- a/Editor/HarmonyPatches/PatchLoader.cs +++ b/Editor/HarmonyPatches/PatchLoader.cs @@ -13,6 +13,7 @@ namespace nadena.dev.modular_avatar.core.editor.HarmonyPatches { private static readonly Action[] patches = new Action[] { + VRCSDKBug_AssemblyGetNameExceptionHandling.Patch, HierarchyViewPatches.Patch, #if UNITY_2022_3_OR_NEWER HandleUtilityPatches.Patch_FilterInstanceIDs, diff --git a/Editor/HarmonyPatches/VRCSDKBug_AssemblyGetNameExceptionHandling.cs b/Editor/HarmonyPatches/VRCSDKBug_AssemblyGetNameExceptionHandling.cs new file mode 100644 index 00000000..e9505c56 --- /dev/null +++ b/Editor/HarmonyPatches/VRCSDKBug_AssemblyGetNameExceptionHandling.cs @@ -0,0 +1,23 @@ +using HarmonyLib; + +namespace nadena.dev.modular_avatar.core.editor.HarmonyPatches +{ + internal static class VRCSDKBug_AssemblyGetNameExceptionHandling + { + internal static void Patch(Harmony h) + { + var t_Tools = AccessTools.TypeByName("VRC.Tools"); + var p_HasTypeVRCApplication = AccessTools.Property(t_Tools, "HasTypeVRCApplication"); + + h.Patch(p_HasTypeVRCApplication.GetMethod, + new HarmonyMethod(typeof(VRCSDKBug_AssemblyGetNameExceptionHandling), nameof(AlwaysFalse))); + } + + private static bool AlwaysFalse(ref bool __result) + { + __result = false; + + return false; + } + } +} \ No newline at end of file diff --git a/Editor/HarmonyPatches/VRCSDKBug_AssemblyGetNameExceptionHandling.cs.meta b/Editor/HarmonyPatches/VRCSDKBug_AssemblyGetNameExceptionHandling.cs.meta new file mode 100644 index 00000000..1b634fe7 --- /dev/null +++ b/Editor/HarmonyPatches/VRCSDKBug_AssemblyGetNameExceptionHandling.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 82d775febe2a4f5eb435d5ac455132db +timeCreated: 1726269002 \ No newline at end of file