Exemple #1
0
        /// <summary>
        /// 添加 AssetBundle 到合集;
        /// </summary>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="IOException"></exception>
        /// <exception cref="FileNotFoundException"></exception>
        private AssetBundleInfo LoadAssetBundle(AssetBundleDescription description)
        {
            if (string.IsNullOrWhiteSpace(description.Name))
            {
                throw new ArgumentException(nameof(description.Name));
            }

            AssetBundleInfo assetBundleInfo;
            int             index = FindAssetBundleInfoIndex(description.Name);

            if (index >= 0)
            {
                throw new ArgumentException(string.Format("已经存在相同的名称的资源:{0}", description.Name));
            }
            else
            {
                AssetBundle assetBundle = LoadAssetBundle(description.RelativePath);
                assetBundleInfo = new AssetBundleInfo(description, assetBundle);
                assetBundles.Add(assetBundleInfo);
                return(assetBundleInfo);
            }
        }
Exemple #2
0
        /// <summary>
        /// 异步添加 AssetBundle 到合集;
        /// </summary>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="IOException"></exception>
        /// <exception cref="FileNotFoundException"></exception>
        private Task <AssetBundleInfo> LoadAssetBundleAsync(AssetBundleDescription description)
        {
            if (string.IsNullOrWhiteSpace(description.Name))
            {
                throw new ArgumentException(nameof(description.Name));
            }

            int index = FindAssetBundleInfoIndex(description.Name);

            if (index >= 0)
            {
                throw new ArgumentException(string.Format("已经存在相同的名称的资源:{0}", description.Name));
            }
            else
            {
                return(LoadAssetBundleAsync(description.RelativePath).ContinueWith(delegate(Task <AssetBundle> task)
                {
                    AssetBundleInfo assetBundleInfo = new AssetBundleInfo(description, task.Result);
                    assetBundles.Add(assetBundleInfo);
                    return assetBundleInfo;
                }));
            }
        }
Exemple #3
0
 public AssetBundleInfo(AssetBundleDescription description, AssetBundle assetBundle)
 {
     Description = description;
     AssetBundle = assetBundle;
 }