Skip to content

Commit 24052ca

Browse files
fix(core): auto-detect manifest decryption in PreprocessBuildCatalog (#626)
* fix(core): auto-detect manifest decryption in PreprocessBuildCatalog Replace the hardcoded null IManifestRestoreServices parameter with a try-all approach that attempts each registered decryption method from EncryptionMapping until one succeeds. This fixes a NRE when building with encrypted manifests (YooAsset#730). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> * docs: add YooAsset extension maintenance rule Add .claude/rules/yooasset-extensions.md to track custom modifications to YooAsset Extension Samples, ensuring the PreprocessBuildCatalog decryption fix is preserved across YooAsset updates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> * chore: update compiled build output Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> --------- Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e9c7bf7 commit 24052ca

File tree

63 files changed

+169
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+169
-118
lines changed
Lines changed: 24 additions & 0 deletions

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Binary file not shown.

UnityProject/Assets/Samples/YooAsset/2.3.18/Extension Sample/Editor/PreprocessBuild/PreprocessBuildCatalog.cs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.IO;
3+
using JEngine.Core.Encrypt;
34
using UnityEngine;
45

56
namespace YooAsset
@@ -30,19 +31,44 @@ public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
3031
{
3132
string packageName = subDirectory.Name;
3233
string pacakgeDirectory = subDirectory.FullName;
33-
try
34+
if (!TryCreateCatalogFile(packageName, pacakgeDirectory))
3435
{
35-
bool result = CatalogTools.CreateCatalogFile(null, packageName, pacakgeDirectory); //TODO 自行处理解密
36-
if (result == false)
37-
{
38-
Debug.LogError($"Create package {packageName} catalog file failed ! See the detail error in console !");
39-
}
36+
Debug.LogError($"Create package {packageName} catalog file failed ! See the detail error in console !");
4037
}
41-
catch (System.Exception ex)
38+
}
39+
}
40+
41+
private static bool TryCreateCatalogFile(string packageName, string packageDirectory)
42+
{
43+
// Try without decryption first (unencrypted manifests)
44+
if (TryCreate(null, packageName, packageDirectory))
45+
return true;
46+
47+
// Try each registered encryption method
48+
foreach (var kvp in EncryptionMapping.Mapping)
49+
{
50+
var restore = kvp.Value.ManifestEncryptionConfig.Decryption;
51+
if (TryCreate(restore, packageName, packageDirectory))
4252
{
43-
Debug.LogError($"Create package {packageName} catalog file failed ! {ex.Message}");
53+
YooLogger.Log($"Package '{packageName}' catalog created using {kvp.Key} decryption.");
54+
return true;
4455
}
4556
}
57+
58+
return false;
59+
}
60+
61+
private static bool TryCreate(IManifestRestoreServices services,
62+
string packageName, string packageDirectory)
63+
{
64+
try
65+
{
66+
return CatalogTools.CreateCatalogFile(services, packageName, packageDirectory);
67+
}
68+
catch
69+
{
70+
return false;
71+
}
4672
}
4773
}
4874
}
Binary file not shown.

UnityProject/Assets/StreamingAssets/yoo/main/5154722f17ed26abd07f0275b2fb315c.bundle.meta renamed to UnityProject/Assets/StreamingAssets/yoo/main/1832d193ad604c285e2456ba2a7855c7.bundle.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

UnityProject/Assets/StreamingAssets/yoo/main/427571ab4f40f72802eba023fca7a5e8.bundle.meta renamed to UnityProject/Assets/StreamingAssets/yoo/main/20c6686ce660502e16a881f74dde76d7.bundle.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)