[fix] 修复Library/PlayerDataCache目录不存在时,PatchScriptingAssembliesJsonHook运行异常的bug

main
walon 2024-07-18 13:37:20 +08:00
parent 2d5f71f6b7
commit 9afbe3bd84
1 changed files with 18 additions and 14 deletions

View File

@ -35,25 +35,29 @@ namespace HybridCLR.MonoHook
private static string BuildMainWindowTitle() private static string BuildMainWindowTitle()
{ {
foreach (var tempJsonPath in Directory.GetDirectories($"{Application.dataPath}/../Library/PlayerDataCache", "*", SearchOption.TopDirectoryOnly)) var cacheDir = $"{Application.dataPath}/../Library/PlayerDataCache";
if (Directory.Exists(cacheDir))
{ {
string dirName = Path.GetFileName(tempJsonPath); foreach (var tempJsonPath in Directory.GetDirectories(cacheDir, "*", SearchOption.TopDirectoryOnly))
#if UNITY_WEIXINMINIGAME
Debug.Assert(EditorUserBuildSettings.activeBuildTarget == BuildTarget.WeixinMiniGame);
if (!dirName.Contains("WeixinMiniGame"))
{ {
continue; string dirName = Path.GetFileName(tempJsonPath);
} #if UNITY_WEIXINMINIGAME
Debug.Assert(EditorUserBuildSettings.activeBuildTarget == BuildTarget.WeixinMiniGame);
if (!dirName.Contains("WeixinMiniGame"))
{
continue;
}
#else #else
Debug.Assert(EditorUserBuildSettings.activeBuildTarget == BuildTarget.WebGL); Debug.Assert(EditorUserBuildSettings.activeBuildTarget == BuildTarget.WebGL);
if (!dirName.Contains("WebGL")) if (!dirName.Contains("WebGL"))
{ {
continue; continue;
} }
#endif #endif
var patcher = new PatchScriptingAssemblyList(); var patcher = new PatchScriptingAssemblyList();
patcher.PathScriptingAssembilesFile(tempJsonPath); patcher.PathScriptingAssembilesFile(tempJsonPath);
}
} }
string newTitle = BuildMainWindowTitleProxy(); string newTitle = BuildMainWindowTitleProxy();