| | |
| | | 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>(); |
| | |
| | | |
| | | 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) |
| | | { |
| | |
| | | // 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) |
| | | { |
| | |
| | | |
| | | 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"); |
| | | |
| | |
| | | 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(); |
| | |
| | | |
| | | _assetBundle.Unload(true); |
| | | _assetBundle = null; |
| | | return UniTask.CompletedTask; |
| | | } |
| | | |
| | | public AssetBundleInfo GetAssetBundleInfo(string assetBundleName) |
| | |
| | | |
| | | 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 |
| | |
| | | #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) |
| | | { |
| | |
| | | |
| | | 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); |