#if UNITY_EDITOR using XGame.Framework.Utils; using XGame.Framework.Asset.Addressable; using UnityEngine; namespace XGame.Framework.Asset { internal partial class LoaderBuilder { private void InitMainBundleEditor() { _isBundleEncrypt = false; var bundlePath = FileUtils.GetAssetBundlePath(Define.MANIFEST_BUNDLE_FULLNAME); _mainbundle = AssetBundle.LoadFromFile(bundlePath);//"kcmanifest.bundle" if (_mainbundle == null) { //Editor下多尝试一次加载 AssetsLog.Debug($"加载未加密Manifest Assetbundle失败,更换为加密方式加载。"); _mainbundle = AssetBundle.LoadFromFile(bundlePath, 0, Define.MANIFEST_BUNDLE_OFFSET); if (_mainbundle != null) { _isBundleEncrypt = true; } else { Log.Error($"Manifest Assetbundle加载失败!"); } } } private IAddressableManifest LoadAddressableManifestEditor() { var manifest = new CSharpAddressableManifest(); var infoSo = LoadAddressableInfosSo(AddressableClassify.BuiltIn); manifest.Init(infoSo); infoSo = LoadAddressableInfosSo(AddressableClassify.Product); manifest.Init(infoSo); infoSo = LoadAddressableInfosSo(AddressableClassify.Tests); manifest.Init(infoSo); return manifest; } private AddressableInfosSo LoadAddressableInfosSo(AddressableClassify classify) { string fileName;// = classify == AddressableClassifyOperation.BuiltIn ? Define.BUILTIN_ASSET_MANIFEST : Define.PRODUCT_ASSET_MANIFEST; if (classify == AddressableClassify.BuiltIn) { fileName = Define.BUILTIN_ASSET_MANIFEST; } else if (classify == AddressableClassify.Tests) { fileName = "TestAssetsManifest"; } else { fileName = Define.PRODUCT_ASSET_MANIFEST; } var manifestPath = $"Assets/AssetConfigs/Addressable/{fileName}.asset"; var assetManifest = UnityEditor.AssetDatabase.LoadAssetAtPath(manifestPath); if (assetManifest == null && classify == AddressableClassify.Product) { Log.Error($"Can't find AddressableInfosSo. Path:{manifestPath}"); } return assetManifest; } } } #endif