public static void AssetBundle_DiscardAssetBundleList(Action onDiscarded, Action <AssetBundlesError, string> onDiscardFailed)
        {
            var cont = CheckAssetBundlesFeatureCondition(
                (code, reason) =>
            {
                onDiscardFailed(code, reason);
            }
                );

            if (!cont)
            {
                return;
            }

            // delete assetBundleList manually.
            var deleted = autoya.DeleteAssetBundleListsFromStorage();

            if (!deleted)
            {
                onDiscardFailed(AssetBundlesError.FailedToDiscardList, "failed to discard list data.");
                return;
            }

            // reset runtime manifest resource infos.
            var currentRuntimeManifest = Autoya.Manifest_LoadRuntimeManifest();

            currentRuntimeManifest.resourceInfos = new AppManifest.RuntimeManifestObject().resourceInfos;
            Autoya.Manifest_UpdateRuntimeManifest(currentRuntimeManifest);

            autoya.assetBundleFeatState = AssetBundlesFeatureState.None;

            onDiscarded();
        }
		private void AddFrameworkHeaderParam (Dictionary<string, string> additionalRequestHeaders) {
			additionalRequestHeaders[AuthSettings.AUTH_REQUESTHEADER_APPVERSION] = Autoya.Manifest_GetBuildManifest().appVerion;

			if (autoya.assetBundleFeatState == AssetBundlesFeatureState.Ready) {
				additionalRequestHeaders[AuthSettings.AUTH_REQUESTHEADER_RESVERSION] = Autoya.Manifest_LoadRuntimeManifest().resVersion;
			}
		}
Beispiel #3
0
        /*
         *      AssetBundles handlers.
         */

        private string AssetBundleListDownloadUrl()
        {
            var targetListVersion = Autoya.Manifest_LoadRuntimeManifest().resVersion;

            if (string.IsNullOrEmpty(targetListVersion))
            {
                return(string.Empty);
            }

            return(AssetBundlesSettings.ASSETBUNDLES_URL_DOWNLOAD_ASSETBUNDLELIST + targetListVersion + "/AssetBundles.StandaloneOSXIntel64_" + targetListVersion.Replace(".", "_") + ".json");
        }
Beispiel #4
0
        /**
         *  should return the url for downloading assetBundle.
         */
        private string OnAssetBundleDownloadUrlRequired(string listIdentity)
        {
            var targetListInfo = Autoya.Manifest_LoadRuntimeManifest().resourceInfos.Where(info => info.listIdentity == listIdentity).FirstOrDefault();

            if (targetListInfo == null)
            {
                throw new Exception("failed to detect bundle info from runtime manifest. requested listIdentity:" + listIdentity + " is not contained in runtime manifest.");
            }

            var url = targetListInfo.listDownloadUrl + "/" + targetListInfo.listIdentity + "/" + AssetBundlesSettings.PLATFORM_STR + "/" + targetListInfo.listVersion + "/";

            return(url);
        }
Beispiel #5
0
        /**
         *  fire when update stored AssetBundleList version parameter from old to new version.
         */
        private void OnUpdateToNewAssetBundleList(string updatedAssetBundleListIdentity, string newVersion)
        {
            var runtimeManifest = Autoya.Manifest_LoadRuntimeManifest();

            foreach (var resInfo in runtimeManifest.resourceInfos)
            {
                if (resInfo.listIdentity == updatedAssetBundleListIdentity)
                {
                    resInfo.listVersion = newVersion;
                    break;
                }
            }
            Autoya.Manifest_UpdateRuntimeManifest(runtimeManifest);
        }
Beispiel #6
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;
        }
Beispiel #8
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;
        }
Beispiel #9
0
 /**
  *  should return identities of AssetBundleLists in persisted place.
  */
 private string[] LoadAppUsingAssetBundleListIdentities()
 {
     return(Autoya.Manifest_LoadRuntimeManifest().resourceInfos.Select(info => info.listIdentity).ToArray());
 }
Beispiel #10
0
 private string[] OnAssetBundleListUrlsRequired()
 {
     return(Autoya.Manifest_LoadRuntimeManifest().resourceInfos.Select(info => autoya.OnAssetBundleListDownloadUrlRequired(info.listIdentity) + info.listIdentity + ".json").ToArray());
 }
Beispiel #11
0
        private string OnResourceVersionRequired()
        {
            var manifest = Autoya.Manifest_LoadRuntimeManifest();

            return(string.Join(",", manifest.resourceInfos.Select(info => info.listIdentity + ":" + info.listVersion).ToArray()));
        }
        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
                        )
                    );
            }
        }