yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
Main/ResModule/AssetBundle/AssetBundleUtility.cs
@@ -5,6 +5,11 @@
using UnityEngine;
using Cysharp.Threading.Tasks;
/// <summary>
/// [Obsolete] US1: 已被 YooAssetService 替代。将在 Phase 10 (T060) 物理删除。
/// 当前仍保留以支持 AssetBundleInitTask 的启动兼容性。
/// </summary>
[System.Obsolete("Use ProjSG.Resource.YooAssetService instead. This class will be removed in Phase 10 (T060).")]
public class AssetBundleUtility : SingletonMonobehaviour<AssetBundleUtility>
{
    private List<AssetBundleInfo> m_AssetBundleInfoList = new List<AssetBundleInfo>();
@@ -19,7 +24,7 @@
    public void InitBuiltInAsset()
    {
        var path = AssetVersionUtility.GetBuiltInAssetFilePath(StringUtility.Contact(AssetVersionUtility.EncodeFileName("builtin"), "_assetbundle"), false);
        var path = AssetVersionUtility.GetBuiltInAssetFilePath(StringUtility.Concat(AssetVersionUtility.EncodeFileName("builtin"), "_assetbundle"), false);
        var assetBundle = AssetBundle.LoadFromFile(path);
        if (assetBundle == null)
        {
@@ -51,7 +56,7 @@
        // CloseAllIgnoreWindowConfig.Release();
        UnloadAssetBundle("builtin/scriptableobjects", true, false);
        var path = AssetVersionUtility.GetBuiltInAssetFilePath(StringUtility.Contact(AssetVersionUtility.EncodeFileName("builtin"), "_assetbundle"), false);
        var path = AssetVersionUtility.GetBuiltInAssetFilePath(StringUtility.Concat(AssetVersionUtility.EncodeFileName("builtin"), "_assetbundle"), false);
        var assetBundle = AssetBundle.LoadFromFile(path);
        if (assetBundle == null)
        {
@@ -99,10 +104,11 @@
    public async UniTask Initialize()
    {
        await UniTask.Delay(200);
        await Co_LoadMainfestFile("audio");
        // await Co_LoadMainfestFile("video");
        await Co_LoadMainfestFile("mobeffectshader");
        // await Co_LoadMainfestFile("config");
        await Co_LoadMainfestFile("config");
        await Co_LoadMainfestFile("maps");
        await Co_LoadMainfestFile("ui");
@@ -113,22 +119,22 @@
        initialized = true;
    }
    private async UniTask Co_LoadMainfestFile(string _category)
    private UniTask Co_LoadMainfestFile(string _category)
    {
        var path = AssetVersionUtility.GetAssetFilePath(StringUtility.Contact(AssetVersionUtility.EncodeFileName(_category), "_assetbundle"), false);
        var path = AssetVersionUtility.GetAssetFilePath(StringUtility.Concat(AssetVersionUtility.EncodeFileName(_category), "_assetbundle"), false);
        var _assetBundle = AssetBundle.LoadFromFile(path);
        if (_assetBundle == null)
        {
            Debug.LogErrorFormat("AssetBundleManifest的包文件为空或者加载出错.  Path:{0}", path);
            return;
            return UniTask.CompletedTask;
        }
        AssetBundleManifest _assetBundleManifest = _assetBundle.LoadAsset<AssetBundleManifest>(ResourcesPath.AssetDependentFileAssetName);
        if (_assetBundleManifest == null)
        {
            Debug.LogErrorFormat("AssetBundleManifest的包文件为空或者加载出错.  Path:{0}", path);
            return;
            return UniTask.CompletedTask;
        }
        string[] _assetBundleNames = _assetBundleManifest.GetAllAssetBundles();
@@ -142,6 +148,7 @@
        _assetBundle.Unload(true);
        _assetBundle = null;
        return UniTask.CompletedTask;
    }
    public AssetBundleInfo GetAssetBundleInfo(string assetBundleName)
@@ -369,7 +376,11 @@
    public UnityEngine.Object Sync_LoadAsset(string assetBundleName, string assetName, Type _type = null)
    {
        if (string.IsNullOrEmpty(assetName))
        {
            Debug.LogErrorFormat("Sync_LoadAsset(): {0}, 出现错误 => 存入的AssetName为null. ", assetName);
            return null;
        }
#if UNITY_5||UNITY_5_3_OR_NEWER
        assetBundleName = assetBundleName.ToLower();
#endif
@@ -496,7 +507,7 @@
#if UNITY_5||UNITY_5_3_OR_NEWER
        assetBundleName = assetBundleName.ToLower();
#endif
        string _assembleName = StringUtility.Contact(assetBundleName, "@", assetName);
        string _assembleName = StringUtility.Concat(assetBundleName, "@", assetName);
        if (JudgeExistAsset(assetBundleName, assetName) == false)
        {
@@ -672,7 +683,7 @@
        m_AssetDict[assetBundleName][assetName] = asset;
        string _assembleName = StringUtility.Contact(assetBundleName, "@", assetName);
        string _assembleName = StringUtility.Concat(assetBundleName, "@", assetName);
        if (m_AssetInfoDict.ContainsKey(_assembleName) == false)
        {
            AssetInfo _assetInfo = new AssetInfo(assetBundleName, assetName);