Esempio n. 1
0
        /// <summary>
        ///  异步递归加载 assetbundle
        /// </summary>
        /// <param name="assetBundleName"></param>
        /// <param name="finishCallback"></param>
        public async UniTask <AssetPackage> LoadAssetBundleAsync(string packageName)
        {
            packageName = StringToLower(packageName);
            AssetPackage package = null;

            if (!allAssetBundleDic.TryGetValue(packageName, out package))
            {
                string[] list = GetAssetBundleDependencies(packageName);
                for (int i = 0; i < list.Length; i++)
                {
                    await LoadAssetBundleAsync(list[i]);
                }

                package = await RawLoadAssetBundleAsync(packageName);
            }
            package?.Retain();
            return(package);
        }
Esempio n. 2
0
        /// <summary>
        ///  一般来说,尽可能使用AssetBundle.LoadFromFile。该API在速度,磁盘使用率和运行时内存使用方面是最有效的
        /// </summary>
        public AssetPackage LoadAssetBundle(string packageName)
        {
            packageName = StringToLower(packageName);
            AssetPackage package = null;

            //判断是否已经加载bundle
            if (!allAssetBundleDic.TryGetValue(packageName, out package))
            {
                //获取依赖
                string[] list = GetAssetBundleDependencies(packageName);
                for (int i = 0; i < list.Length; i++)
                {
                    //加载依赖
                    LoadAssetBundle(list[i]);
                }

                package = RawLoadAssetBundle(packageName);
            }

            package?.Retain();
            return(package);
        }