From 3123d9e2242594571709436a170db4f90144affc Mon Sep 17 00:00:00 2001 From: bd_ Date: Fri, 13 Sep 2024 15:27:35 -0700 Subject: [PATCH] chore: workaround VRCSDK bug https://feedback.vrchat.com/sdk-bug-reports/p/string-conversion-errors-from-runtimeassemblygetcodebase-with-japanese-locale-an --- CHANGELOG.md | 3 +++ Editor/{PreviewSystem => }/Harmony.meta | 0 .../Harmony/HandleUtilityPatches.cs | 0 .../Harmony/HandleUtilityPatches.cs.meta | 0 Editor/{PreviewSystem => }/Harmony/Patcher.cs | 1 + .../Harmony/Patcher.cs.meta | 0 .../Harmony/PickingObjectPatch.cs | 0 .../Harmony/PickingObjectPatch.cs.meta | 0 ...SDKBug_AssemblyGetNameExceptionHandling.cs | 23 +++++++++++++++++++ ...g_AssemblyGetNameExceptionHandling.cs.meta | 3 +++ 10 files changed, 30 insertions(+) rename Editor/{PreviewSystem => }/Harmony.meta (100%) rename Editor/{PreviewSystem => }/Harmony/HandleUtilityPatches.cs (100%) rename Editor/{PreviewSystem => }/Harmony/HandleUtilityPatches.cs.meta (100%) rename Editor/{PreviewSystem => }/Harmony/Patcher.cs (93%) rename Editor/{PreviewSystem => }/Harmony/Patcher.cs.meta (100%) rename Editor/{PreviewSystem => }/Harmony/PickingObjectPatch.cs (100%) rename Editor/{PreviewSystem => }/Harmony/PickingObjectPatch.cs.meta (100%) create mode 100644 Editor/Harmony/VRCSDKBug_AssemblyGetNameExceptionHandling.cs create mode 100644 Editor/Harmony/VRCSDKBug_AssemblyGetNameExceptionHandling.cs.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index 13c7bbd..eb27ea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [#379] Fix CurrentThreadIsMainThread assertion in AsyncProfiler +- [#386] + Workaround [VRCSDK bug](https://feedback.vrchat.com/sdk-bug-reports/p/string-conversion-errors-from-runtimeassemblygetcodebase-with-japanese-locale-an) + caused by non-ASCII project paths. ### Changed diff --git a/Editor/PreviewSystem/Harmony.meta b/Editor/Harmony.meta similarity index 100% rename from Editor/PreviewSystem/Harmony.meta rename to Editor/Harmony.meta diff --git a/Editor/PreviewSystem/Harmony/HandleUtilityPatches.cs b/Editor/Harmony/HandleUtilityPatches.cs similarity index 100% rename from Editor/PreviewSystem/Harmony/HandleUtilityPatches.cs rename to Editor/Harmony/HandleUtilityPatches.cs diff --git a/Editor/PreviewSystem/Harmony/HandleUtilityPatches.cs.meta b/Editor/Harmony/HandleUtilityPatches.cs.meta similarity index 100% rename from Editor/PreviewSystem/Harmony/HandleUtilityPatches.cs.meta rename to Editor/Harmony/HandleUtilityPatches.cs.meta diff --git a/Editor/PreviewSystem/Harmony/Patcher.cs b/Editor/Harmony/Patcher.cs similarity index 93% rename from Editor/PreviewSystem/Harmony/Patcher.cs rename to Editor/Harmony/Patcher.cs index 9bd4234..c06ed00 100644 --- a/Editor/PreviewSystem/Harmony/Patcher.cs +++ b/Editor/Harmony/Patcher.cs @@ -15,6 +15,7 @@ internal sealed class PatchLoader { HandleUtilityPatches.Patch_FilterInstanceIDs, PickingObjectPatch.Patch, + VRCSDKBug_AssemblyGetNameExceptionHandling.Patch //HierarchyViewPatches.Patch }; diff --git a/Editor/PreviewSystem/Harmony/Patcher.cs.meta b/Editor/Harmony/Patcher.cs.meta similarity index 100% rename from Editor/PreviewSystem/Harmony/Patcher.cs.meta rename to Editor/Harmony/Patcher.cs.meta diff --git a/Editor/PreviewSystem/Harmony/PickingObjectPatch.cs b/Editor/Harmony/PickingObjectPatch.cs similarity index 100% rename from Editor/PreviewSystem/Harmony/PickingObjectPatch.cs rename to Editor/Harmony/PickingObjectPatch.cs diff --git a/Editor/PreviewSystem/Harmony/PickingObjectPatch.cs.meta b/Editor/Harmony/PickingObjectPatch.cs.meta similarity index 100% rename from Editor/PreviewSystem/Harmony/PickingObjectPatch.cs.meta rename to Editor/Harmony/PickingObjectPatch.cs.meta diff --git a/Editor/Harmony/VRCSDKBug_AssemblyGetNameExceptionHandling.cs b/Editor/Harmony/VRCSDKBug_AssemblyGetNameExceptionHandling.cs new file mode 100644 index 0000000..02aa3d7 --- /dev/null +++ b/Editor/Harmony/VRCSDKBug_AssemblyGetNameExceptionHandling.cs @@ -0,0 +1,23 @@ +using HarmonyLib; + +namespace nadena.dev.ndmf.preview +{ + 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/Harmony/VRCSDKBug_AssemblyGetNameExceptionHandling.cs.meta b/Editor/Harmony/VRCSDKBug_AssemblyGetNameExceptionHandling.cs.meta new file mode 100644 index 0000000..c82d172 --- /dev/null +++ b/Editor/Harmony/VRCSDKBug_AssemblyGetNameExceptionHandling.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9b7853fc600d4524be1434b9972befc5 +timeCreated: 1726266065 \ No newline at end of file