Ejemplo n.º 1
0
        private void DownloadBundleWithDependencies(string bundleName, Action <AssetBundle> callback)
        {
            if (Initialized)
            {
                string remapName = RemapVariantName(bundleName);

                if (DownloadedBundle(remapName).IsNull())
                {
                    Hash128 hash = m_AssetManifest.GetAssetBundleHash(remapName);
                    AssetBundleDownloader downloader = new AssetBundleDownloader(BaseUri, remapName, hash, (bundle) =>
                    {
                        if (bundle.IsNotNull())
                        {
                            InsertBundle(remapName, bundle);

                            string[] dependencies = m_AssetManifest.GetAllDependencies(remapName);
                            DependenciesDownload(new DependenciesContainer(remapName, dependencies, callback));
                        }
                        else
                        {
                            callback(null);
                        }
                    });

                    StartCoroutine(downloader.Download());
                }
                else
                {
                    string[] dependencies = m_AssetManifest.GetAllDependencies(remapName);
                    DependenciesDownload(new DependenciesContainer(remapName, dependencies, callback));
                }
            }
        }
Ejemplo n.º 2
0
        private void DependenciesDownload(DependenciesContainer container)
        {
            if (container.Bundles.Empty())
            {
                container.OnComplete(DownloadedBundle(container.BundleName));
            }
            else
            {
                string targetBundleName = RemapVariantName(container.Bundles.Pop());
                if (DownloadedBundle(targetBundleName).IsNull())
                {
                    Hash128 hash = m_AssetManifest.GetAssetBundleHash(targetBundleName);
                    AssetBundleDownloader downloader = new AssetBundleDownloader(BaseUri, targetBundleName, hash, (bundle) =>
                    {
                        if (bundle.IsNotNull())
                        {
                            InsertBundle(targetBundleName, bundle);

                            DependenciesDownload(container);
                        }
                        else
                        {
                            container.OnComplete(null);
                        }
                    });

                    StartCoroutine(downloader.Download());
                }
                else
                {
                    DependenciesDownload(container);
                }
            }
        }
Ejemplo n.º 3
0
        private void DownloadBundle(string bundleName, Action <AssetBundle> callback)
        {
            if (bundleName.IsValidText())
            {
                string remapName = RemapVariantName(bundleName);

                if (DownloadedBundle(remapName).IsNull())
                {
                    Hash128 hash = m_AssetManifest.GetAssetBundleHash(remapName);
                    AssetBundleDownloader downloader = new AssetBundleDownloader(BaseUri, remapName, hash, (bundle) =>
                    {
                        InsertBundle(remapName, bundle);

                        callback(bundle);
                    });

                    StartCoroutine(downloader.Download());
                }
                else
                {
                    callback(DownloadedBundle(remapName));
                }
            }
            else
            {
                callback(null);
            }
        }