From 0a2ecc5de6394cd538b9e4fc9901a52fd2b2aa8d Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 22 五月 2026 18:43:05 +0800
Subject: [PATCH] 漏提交内容

---
 Assets/Editor/AssetBundleBrowser/FixGhostAsset.cs        |   52 +++++++
 Assets/Editor/YooAsset/CollectResBeforeUpdate.cs.meta    |   11 +
 Assets/Editor/YooAsset/CollectBuiltinAfterUpdate.cs      |   10 +
 Assets/Editor/AssetBundleBrowser/FixGhostAsset.cs.meta   |   11 +
 Assets/Editor/YooAsset/CollectBuiltinAfterUpdate.cs.meta |   11 +
 Assets/Editor/YooAsset/CollectResBeforeUpdate.cs         |  302 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 397 insertions(+), 0 deletions(-)

diff --git a/Assets/Editor/AssetBundleBrowser/FixGhostAsset.cs b/Assets/Editor/AssetBundleBrowser/FixGhostAsset.cs
new file mode 100644
index 0000000..f3cb325
--- /dev/null
+++ b/Assets/Editor/AssetBundleBrowser/FixGhostAsset.cs
@@ -0,0 +1,52 @@
+using System.IO;
+using UnityEditor;
+using UnityEngine;
+
+
+public static class FixGhostAsset
+{
+    [MenuItem("Tools/Fix Ghost Asset")]
+    public static void Fix()
+    {
+        const string ghost = "Assets/ResourcesOut/Sprite/HeroDebutHero_510016/HeroDebutSkinTabInfo_5100161.png";
+        var guid = AssetDatabase.AssetPathToGUID(ghost);
+        var type = AssetDatabase.GetMainAssetTypeAtPath(ghost);
+        Debug.Log($"[Ghost] path={ghost}\n  GUID={guid}\n  Type={type}");
+
+        // 鐩存帴璁� Unity 浠庣储寮曢噷鍒犳帀
+        var ok = AssetDatabase.DeleteAsset(ghost);
+        Debug.Log($"[Ghost] DeleteAsset -> {ok}");
+
+        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
+    }
+
+    /// <summary>
+    /// 鍒犻櫎 YooAsset 鐨� AssetDependencyDB 渚濊禆缂撳瓨銆�
+    /// 褰撳嚭鐜� "Found invalid asset : ..." 杩欑被鎸囧悜宸插垹闄よ祫婧愮殑鎶ラ敊鏃惰皟鐢ㄣ��
+    /// 璇� DB 缂撳瓨浜嗘棫鐨� GUID鈫扐ssetPath 鏄犲皠锛岀鐩樻枃浠跺垹闄ゅ悗瀹冧笉浼氳嚜鍔ㄥけ鏁堬紝
+    /// 鍒犻櫎鏂囦欢鍚� YooAsset 浼氬湪涓嬫鎵撳寘鏃惰嚜鍔ㄩ噸寤恒��
+    /// </summary>
+    [MenuItem("Tools/Clear YooAsset DependencyDB")]
+    public static void ClearYooAssetDependencyDB()
+    {
+        string projectRoot = Path.GetFullPath(Path.Combine(Application.dataPath, ".."));
+        string dbPath = Path.Combine(projectRoot, "Library", "AssetDependencyDB");
+
+        if (File.Exists(dbPath))
+        {
+            try
+            {
+                File.Delete(dbPath);
+                Debug.Log($"[FixGhostAsset] 宸插垹闄� YooAsset 渚濊禆缂撳瓨: {dbPath}\n涓嬫鎵撳寘灏嗚嚜鍔ㄩ噸寤恒��");
+            }
+            catch (System.Exception ex)
+            {
+                Debug.LogError($"[FixGhostAsset] 鍒犻櫎 AssetDependencyDB 澶辫触: {ex.Message}");
+            }
+        }
+        else
+        {
+            Debug.Log($"[FixGhostAsset] AssetDependencyDB 涓嶅瓨鍦紙鍙兘宸插垹闄ゆ垨灏氭湭鐢熸垚锛�: {dbPath}");
+        }
+    }
+}
\ No newline at end of file
diff --git a/Assets/Editor/AssetBundleBrowser/FixGhostAsset.cs.meta b/Assets/Editor/AssetBundleBrowser/FixGhostAsset.cs.meta
new file mode 100644
index 0000000..d21fc11
--- /dev/null
+++ b/Assets/Editor/AssetBundleBrowser/FixGhostAsset.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: dc14395ba27efe14d91a69e4983c8a6c
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Editor/YooAsset/CollectBuiltinAfterUpdate.cs b/Assets/Editor/YooAsset/CollectBuiltinAfterUpdate.cs
new file mode 100644
index 0000000..d0e4fd8
--- /dev/null
+++ b/Assets/Editor/YooAsset/CollectBuiltinAfterUpdate.cs
@@ -0,0 +1,10 @@
+using YooAsset.Editor;
+
+[DisplayName("鏀堕泦BuiltIn(鎺掗櫎鐑洿鍓嶈祫婧�)")]
+public class CollectBuiltinAfterUpdate : IFilterRule
+{
+    public bool IsCollectAsset(FilterRuleData data)
+    {
+        return !CollectResBeforeUpdate.IsBeforeUpdateBuiltinAsset(data.AssetPath);
+    }
+}
diff --git a/Assets/Editor/YooAsset/CollectBuiltinAfterUpdate.cs.meta b/Assets/Editor/YooAsset/CollectBuiltinAfterUpdate.cs.meta
new file mode 100644
index 0000000..f676ad9
--- /dev/null
+++ b/Assets/Editor/YooAsset/CollectBuiltinAfterUpdate.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: da4dc54ec24d90b488d2747e4a4b34c5
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Editor/YooAsset/CollectResBeforeUpdate.cs b/Assets/Editor/YooAsset/CollectResBeforeUpdate.cs
new file mode 100644
index 0000000..3fac15c
--- /dev/null
+++ b/Assets/Editor/YooAsset/CollectResBeforeUpdate.cs
@@ -0,0 +1,302 @@
+using System;
+using System.IO;
+using UnityEditor;
+using UnityEngine;
+using YooAsset.Editor;
+
+public static class CollectResBeforeUpdate
+{
+    private const string BuiltinPackageName = "Builtin";
+    private const string PrefabPackageName = "Prefab";
+    private const string GroupName = "ResBeforeUpdate";
+    private const string AfterUpdateGroupName = "BuiltinAfterUpdate";
+    private const string CollectBuiltinAfterUpdateRuleName = "CollectBuiltinAfterUpdate";
+    private const string BuiltInRoot = "Assets/ResourcesOut/BuiltIn";
+    private const string ConfigRoot = "Assets/ResourcesOut/Config";
+    private const string InitialFunctionPath = ConfigRoot + "/InitialFunction.txt";
+    private const string ResourcesInitialFunctionPath = "Assets/Resources/Config/InitialFunction.txt";
+
+    private static readonly string[] BeforeUpdateBuiltinAssetPaths =
+    {
+        BuiltInRoot + "/Prefabs/LaunchExWin.prefab",
+        BuiltInRoot + "/Sprites/TY_TB_JH1.png",
+        BuiltInRoot + "/Sprites/TY_TB_JH2.png",
+        BuiltInRoot + "/Sprites/LoadingBottom.png",
+        BuiltInRoot + "/Sprites/LoadingSlider.png",
+    };
+
+    private static readonly string[] BuiltinConfigPaths =
+    {
+        ConfigRoot + "/Contact.txt",
+        ConfigRoot + "/HelpInfo.txt",
+        ConfigRoot + "/PriorBundle.txt",
+        ConfigRoot + "/PriorLanguage.txt",
+        ConfigRoot + "/ApkUpdateUrl.txt",
+        InitialFunctionPath,
+    };
+
+    [MenuItem("YooAsset宸ュ叿/鏀堕泦鐑洿鍓嶈祫婧愬埌Builtin", false, 202)]
+    public static void Execute()
+    {
+        var changed = SyncCollectors();
+        EditorUtility.DisplayDialog(
+            "CollectResBeforeUpdate",
+            changed ? "鐑洿鍓嶈祫婧愬凡鍚屾鍒� Builtin Package銆�" : "鐑洿鍓嶈祫婧愭敹闆嗛厤缃凡缁忔槸鏈�鏂般��",
+            "纭畾");
+    }
+
+    public static bool SyncCollectors()
+    {
+        var setting = AssetBundleCollectorSettingData.Setting;
+        var changed = false;
+
+        var builtinPackage = setting.Packages.Find(package => package.PackageName == BuiltinPackageName);
+        if (builtinPackage == null)
+        {
+            builtinPackage = AssetBundleCollectorSettingData.CreatePackage(BuiltinPackageName);
+            changed = true;
+            Debug.Log($"[CollectResBeforeUpdate] 鍒涘缓 Package: {BuiltinPackageName}");
+        }
+
+        var group = builtinPackage.Groups.Find(item => item.GroupName == GroupName);
+        if (group == null)
+        {
+            group = AssetBundleCollectorSettingData.CreateGroup(builtinPackage, GroupName);
+            changed = true;
+            Debug.Log($"[CollectResBeforeUpdate] 鍒涘缓 Group: {GroupName}");
+        }
+
+        changed |= RemoveObsoleteBuiltinRootCollectors(builtinPackage);
+        changed |= RemoveDuplicateBeforeUpdateCollectors(setting, builtinPackage, group);
+        foreach (var assetPath in BeforeUpdateBuiltinAssetPaths)
+        {
+            changed |= EnsureCollector(group, assetPath, nameof(PackSeparately), nameof(CollectAll));
+        }
+
+        foreach (var configPath in BuiltinConfigPaths)
+        {
+            changed |= EnsureCollector(group, configPath, nameof(PackSeparately), nameof(CollectAll));
+        }
+
+        changed |= EnsureAfterUpdateBuiltinCollector(setting);
+        changed |= SyncResourcesInitialFunction();
+
+        if (changed)
+        {
+            AssetBundleCollectorSettingData.SaveFile();
+            AssetDatabase.Refresh();
+            Debug.Log("[CollectResBeforeUpdate] 鐑洿鍓嶈祫婧愭敹闆嗛厤缃凡鍚屾銆侭uiltin 鍙繚鐣� Launch 鐧藉悕鍗曪紝鍏朵綑 BuiltIn 璧勬簮鐢� Prefab 鍖呮敹闆嗐��");
+        }
+        else
+        {
+            Debug.Log("[CollectResBeforeUpdate] 鐑洿鍓嶈祫婧愭敹闆嗛厤缃棤闇�鏇存柊銆�");
+        }
+
+        return changed;
+    }
+
+    public static bool IsBeforeUpdateBuiltinAsset(string assetPath)
+    {
+        foreach (var beforeUpdatePath in BeforeUpdateBuiltinAssetPaths)
+        {
+            if (IsSameAssetPath(assetPath, beforeUpdatePath))
+                return true;
+        }
+
+        return false;
+    }
+
+    private static bool EnsureAfterUpdateBuiltinCollector(AssetBundleCollectorSetting setting)
+    {
+        var prefabPackage = setting.Packages.Find(package => package.PackageName == PrefabPackageName);
+        if (prefabPackage == null)
+        {
+            prefabPackage = AssetBundleCollectorSettingData.CreatePackage(PrefabPackageName);
+            Debug.Log($"[CollectResBeforeUpdate] 鍒涘缓 Package: {PrefabPackageName}");
+        }
+
+        var group = prefabPackage.Groups.Find(item => item.GroupName == AfterUpdateGroupName);
+        if (group == null)
+        {
+            group = AssetBundleCollectorSettingData.CreateGroup(prefabPackage, AfterUpdateGroupName);
+            Debug.Log($"[CollectResBeforeUpdate] 鍒涘缓 Group: {AfterUpdateGroupName}");
+        }
+
+        return EnsureCollector(group, BuiltInRoot, nameof(PackDirectory), CollectBuiltinAfterUpdateRuleName);
+    }
+
+    private static bool RemoveObsoleteBuiltinRootCollectors(AssetBundleCollectorPackage builtinPackage)
+    {
+        var changed = false;
+        foreach (var group in builtinPackage.Groups)
+        {
+            for (var index = group.Collectors.Count - 1; index >= 0; index--)
+            {
+                var collector = group.Collectors[index];
+                if (!IsSameAssetPath(collector.CollectPath, BuiltInRoot))
+                    continue;
+
+                AssetBundleCollectorSettingData.RemoveCollector(group, collector);
+                changed = true;
+                Debug.Log($"[CollectResBeforeUpdate] 浠� Builtin Package 绉婚櫎鏁寸洰褰� Collector: {collector.CollectPath}");
+            }
+        }
+
+        return changed;
+    }
+
+    private static bool RemoveDuplicateBeforeUpdateCollectors(
+        AssetBundleCollectorSetting setting,
+        AssetBundleCollectorPackage builtinPackage,
+        AssetBundleCollectorGroup targetGroup)
+    {
+        var changed = false;
+        foreach (var package in setting.Packages)
+        {
+            foreach (var group in package.Groups)
+            {
+                for (var index = group.Collectors.Count - 1; index >= 0; index--)
+                {
+                    var collector = group.Collectors[index];
+                    if (!IsExactBeforeUpdateCollectPath(collector.CollectPath))
+                        continue;
+
+                    if (package == builtinPackage && group == targetGroup)
+                        continue;
+
+                    AssetBundleCollectorSettingData.RemoveCollector(group, collector);
+                    changed = true;
+                    Debug.Log($"[CollectResBeforeUpdate] 浠� Package '{package.PackageName}' 绉婚櫎閲嶅 Collector: {collector.CollectPath}");
+                }
+            }
+        }
+
+        return changed;
+    }
+
+    private static bool EnsureCollector(AssetBundleCollectorGroup group, string collectPath, string packRuleName, string filterRuleName)
+    {
+        var collectorGuid = AssetDatabase.AssetPathToGUID(collectPath);
+        if (string.IsNullOrEmpty(collectorGuid))
+        {
+            Debug.LogWarning($"[CollectResBeforeUpdate] 璺宠繃涓嶅瓨鍦ㄧ殑璧勬簮: {collectPath}");
+            return false;
+        }
+
+        var changed = false;
+        AssetBundleCollector target = null;
+
+        for (var index = group.Collectors.Count - 1; index >= 0; index--)
+        {
+            var collector = group.Collectors[index];
+            if (!IsSameAssetPath(collector.CollectPath, collectPath))
+                continue;
+
+            if (target == null)
+            {
+                target = collector;
+            }
+            else
+            {
+                AssetBundleCollectorSettingData.RemoveCollector(group, collector);
+                changed = true;
+                Debug.Log($"[CollectResBeforeUpdate] 绉婚櫎閲嶅 Collector: {collector.CollectPath}");
+            }
+        }
+
+        if (target == null)
+        {
+            target = new AssetBundleCollector { CollectPath = collectPath };
+            AssetBundleCollectorSettingData.CreateCollector(group, target);
+            changed = true;
+            Debug.Log($"[CollectResBeforeUpdate] 鍒涘缓 Collector: {collectPath}");
+        }
+
+        changed |= SetString(ref target.CollectPath, collectPath);
+        changed |= SetString(ref target.CollectorGUID, collectorGuid);
+        if (target.CollectorType != ECollectorType.MainAssetCollector)
+        {
+            target.CollectorType = ECollectorType.MainAssetCollector;
+            changed = true;
+        }
+
+        changed |= SetString(ref target.AddressRuleName, nameof(AddressByRelativePath));
+        changed |= SetString(ref target.PackRuleName, packRuleName);
+        changed |= SetString(ref target.FilterRuleName, filterRuleName);
+        changed |= SetString(ref target.AssetTags, string.Empty);
+        changed |= SetString(ref target.UserData, string.Empty);
+
+        if (changed)
+            AssetBundleCollectorSettingData.ModifyCollector(group, target);
+        return changed;
+    }
+
+    private static bool SyncResourcesInitialFunction()
+    {
+        var sourceFullPath = ToProjectFullPath(InitialFunctionPath);
+        if (!File.Exists(sourceFullPath))
+        {
+            Debug.LogError($"[CollectResBeforeUpdate] 鎵句笉鍒� ResourcesOut InitialFunction: {InitialFunctionPath}");
+            return false;
+        }
+
+        var targetFullPath = ToProjectFullPath(ResourcesInitialFunctionPath);
+        var targetDirectory = Path.GetDirectoryName(targetFullPath);
+        if (!Directory.Exists(targetDirectory))
+            Directory.CreateDirectory(targetDirectory);
+
+        var sourceText = File.ReadAllText(sourceFullPath);
+        if (File.Exists(targetFullPath) && File.ReadAllText(targetFullPath) == sourceText)
+            return false;
+
+        File.WriteAllText(targetFullPath, sourceText);
+        AssetDatabase.ImportAsset(ResourcesInitialFunctionPath);
+        Debug.Log($"[CollectResBeforeUpdate] 宸插悓姝� Resources InitialFunction: {ResourcesInitialFunctionPath}");
+        return true;
+    }
+
+    private static bool IsExactBeforeUpdateCollectPath(string collectPath)
+    {
+        if (IsSameAssetPath(collectPath, BuiltInRoot))
+            return false;
+
+        foreach (var beforeUpdatePath in BeforeUpdateBuiltinAssetPaths)
+        {
+            if (IsSameAssetPath(collectPath, beforeUpdatePath))
+                return true;
+        }
+
+        foreach (var configPath in BuiltinConfigPaths)
+        {
+            if (IsSameAssetPath(collectPath, configPath))
+                return true;
+        }
+
+        return false;
+    }
+
+    private static bool IsSameAssetPath(string lhs, string rhs)
+    {
+        return NormalizeAssetPath(lhs).Equals(NormalizeAssetPath(rhs), StringComparison.OrdinalIgnoreCase);
+    }
+
+    private static string ToProjectFullPath(string assetPath)
+    {
+        var projectRoot = Directory.GetParent(Application.dataPath).FullName;
+        return Path.Combine(projectRoot, NormalizeAssetPath(assetPath));
+    }
+
+    private static string NormalizeAssetPath(string assetPath)
+    {
+        return string.IsNullOrEmpty(assetPath) ? string.Empty : assetPath.Replace('\\', '/').TrimEnd('/');
+    }
+
+    private static bool SetString(ref string target, string value)
+    {
+        if (target == value)
+            return false;
+
+        target = value;
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/Assets/Editor/YooAsset/CollectResBeforeUpdate.cs.meta b/Assets/Editor/YooAsset/CollectResBeforeUpdate.cs.meta
new file mode 100644
index 0000000..727b69d
--- /dev/null
+++ b/Assets/Editor/YooAsset/CollectResBeforeUpdate.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7c219d6f90e14464290e8f4b420d26a1
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
\ No newline at end of file

--
Gitblit v1.8.0