示例#1
0
        private static void Internal_AssetBundle_DownloadAssetBundleListFromUrl(string listUrl, Action <ListDownloadResult> downloadSucceeded, Action <ListDownloadError, string, AutoyaStatus> downloadFailed, double timeoutSec = AssetBundlesSettings.TIMEOUT_SEC)
        {
            Action act = () => {
                autoya.mainthreadDispatcher.Commit(
                    autoya._assetBundleListDownloader.DownloadAssetBundleList(
                        listUrl,
                        newList => {
                    var result = autoya.StoreAssetBundleListToStorage(newList);
                    if (result)
                    {
                        // update runtime manifest. set "resVersion" to downloaded version.
                        {
                            var runtimeManifest        = Autoya.Manifest_LoadRuntimeManifest();
                            runtimeManifest.resVersion = newList.version;
                            Autoya.Manifest_UpdateRuntimeManifest(runtimeManifest);
                        }

                        autoya._currentAssetBundleList = newList;

                        // set state to loaded.
                        autoya.assetBundleFeatState = AssetBundlesFeatureState.Ready;
                        autoya.ReadyLoaderAndPreloader();

                        downloadSucceeded(ListDownloadResult.ListDownloaded);
                        return;
                    }

                    // failed to store assetBundleList.
                    autoya.assetBundleFeatState = AssetBundlesFeatureState.None;
                    downloadFailed(ListDownloadError.FailedToStoreDownloadedAssetBundleList, "failed to store AssetBundleList to storage. let's check StoreAssetBundleListToStorage method.", new AutoyaStatus());
                },
                        (code, reason, autoyaStatus) => {
                    autoya.assetBundleFeatState = AssetBundlesFeatureState.None;
                    downloadFailed(ListDownloadError.FailedToDownload, "code:" + code + " reason]" + reason, autoyaStatus);
                },
                        timeoutSec
                        )
                    );
            };

            autoya.mainthreadDispatcher.Commit(
                autoya.ListLoaderCoroutine(act)
                );
        }
        private void OnUpdatingListReceived(AssetBundleList newList)
        {
            var assetUsingCondition = GetCurrentAssetBundleUsingCondition(newList);

            if (ShouldUpdateToNewAssetBundleList(assetUsingCondition))
            {
                var result = StoreAssetBundleListToStorage(newList);
                if (result)
                {
                    // update runtime manifest.
                    {
                        var newListIdentity = newList.identity;
                        var runtimeManifest = Autoya.Manifest_LoadRuntimeManifest();
                        foreach (var resInfo in runtimeManifest.resourceInfos)
                        {
                            if (resInfo.listIdentity == newListIdentity)
                            {
                                resInfo.listVersion = newList.version;
                                break;
                            }
                        }
                        Autoya.Manifest_UpdateRuntimeManifest(runtimeManifest);
                    }

                    ReadyLoaderAndPreloader(newList);

                    // finish downloading new assetBundleList.
                    newListDownloaderState = NewListDownloaderState.Ready;
                    return;
                }

                // failed to store new assetBundleList.
            }

            // finish downloading new assetBundleList.
            newListDownloaderState = NewListDownloaderState.Ready;
            return;
        }
示例#3
0
        private void OnUpdatingListReceived(AssetBundleList newList)
        {
            var assetUsingCondition = GetCurrentAssetBundleUsingCondition(newList);

            if (ShouldUpdateToNewAssetBundleList(assetUsingCondition))
            {
                var result = StoreAssetBundleListToStorage(newList);
                if (result)
                {
                    // update runtime manifest. set "resVersion" to downloaded version.
                    {
                        var runtimeManifest = Autoya.Manifest_LoadRuntimeManifest();
                        runtimeManifest.resVersion = newList.version;
                        Autoya.Manifest_UpdateRuntimeManifest(runtimeManifest);
                    }

                    _currentAssetBundleList = newList;

                    // discard postponed cache.
                    _postponedNewAssetBundleList = null;

                    // finish downloading new assetBundleList.
                    newListDownloaderState = NewListDownloaderState.Ready;
                    return;
                }

                // failed to store new assetBundleList.
            }

            // store on memory as postponed.
            // list is not updated actually.
            _postponedNewAssetBundleList = newList;

            // finish downloading new assetBundleList.
            newListDownloaderState = NewListDownloaderState.Ready;
            return;
        }
        private void Internal_AssetBundle_DownloadAssetBundleListFromUrl(string[] listUrls, Action <ListDownloadResult> downloadSucceeded, Action <ListDownloadError, string, AutoyaStatus> downloadFailed, double timeoutSec = AssetBundlesSettings.TIMEOUT_SEC)
        {
            assetBundleFeatState = AssetBundlesFeatureState.ListDownoading;

            var wholeAssetBundleListCount = listUrls.Length;

            var isDownloadFailed = false;

            var downloadedListIdentities       = new List <string>();
            Action <AssetBundleList> succeeded = newList =>
            {
                /**
                 *  リストの保存に失敗した場合、全ての処理が失敗した扱いになる。
                 */
                var result = StoreAssetBundleListToStorage(newList);
                if (result)
                {
                    // update runtime manifest. set "resVersion" to downloaded version.
                    {
                        var newListIdentity = newList.identity;
                        var runtimeManifest = Autoya.Manifest_LoadRuntimeManifest();
                        foreach (var resInfo in runtimeManifest.resourceInfos)
                        {
                            if (resInfo.listIdentity == newListIdentity)
                            {
                                resInfo.listVersion = newList.version;
                                break;
                            }
                        }
                        Autoya.Manifest_UpdateRuntimeManifest(runtimeManifest);
                    }

                    // update list in loader.
                    ReadyLoaderAndPreloader(newList);

                    downloadedListIdentities.Add(newList.identity);
                    if (downloadedListIdentities.Count == wholeAssetBundleListCount)
                    {
                        // set state to loaded.
                        autoya.assetBundleFeatState = AssetBundlesFeatureState.Ready;

                        // fire downloaded.
                        downloadSucceeded(ListDownloadResult.ListDownloaded);
                    }
                }
                else
                {
                    if (isDownloadFailed)
                    {
                        return;
                    }
                    isDownloadFailed = true;
                    downloadFailed(ListDownloadError.FailedToStoreDownloadedAssetBundleList, "failed to store assetBundleList info to device. downloaded list identity:" + newList.identity, new AutoyaStatus());
                }
            };


            foreach (var listUrl in listUrls)
            {
                /*
                 *  どれか一件でも失敗したら、リスト機構の初期化に失敗する。
                 */
                Action <int, string, AutoyaStatus> failed = (code, reason, autoyaStatus) =>
                {
                    if (isDownloadFailed)
                    {
                        return;
                    }
                    isDownloadFailed = true;

                    assetBundleFeatState = AssetBundlesFeatureState.None;
                    downloadFailed(ListDownloadError.FailedToDownload, "code:" + code + " reason:" + reason + " url:" + listUrl, autoyaStatus);
                };

                // parallel.
                mainthreadDispatcher.Commit(
                    _assetBundleListDownloader.DownloadAssetBundleList(
                        listUrl,
                        succeeded,
                        failed,
                        timeoutSec
                        )
                    );
            }
        }