Find resource storage type via known assemblies

This commit is contained in:
2025-12-14 13:20:48 +01:00
parent 1035f06884
commit c074a86423

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
@@ -12,11 +11,11 @@ namespace KCM
private static MethodInfo isPrivateMethod; private static MethodInfo isPrivateMethod;
private static MethodInfo addResourceStorageMethod; private static MethodInfo addResourceStorageMethod;
private static readonly string[] resourceStorageTypeNames = new[] private static readonly Assembly[] candidateAssemblies = new[]
{ {
"Assets.Interface.IResourceStorage, Assembly-CSharp", typeof(Player).Assembly,
"Assets.Interface.IResourceStorage, Assembly-CSharp-firstpass", typeof(World).Assembly,
"Assets.Interface.IResourceStorage, Assembly-CSharp-Editor", typeof(FreeResourceManager).Assembly,
}; };
private static void EnsureInitialized() private static void EnsureInitialized()
@@ -24,9 +23,12 @@ namespace KCM
if (resourceStorageType != null) if (resourceStorageType != null)
return; return;
foreach (var typeName in resourceStorageTypeNames) foreach (var assembly in candidateAssemblies)
{ {
resourceStorageType = Type.GetType(typeName); if (assembly == null)
continue;
resourceStorageType = assembly.GetType("Assets.Interface.IResourceStorage", false);
if (resourceStorageType != null) if (resourceStorageType != null)
break; break;
} }