/* * Initializer */ private void InitializeAssetBundleFeature() { // initialize AssetBundleListDownloader. AssetBundleListDownloader.HttpResponseHandlingDelegate httpResponseHandlingDel = (p1, p2, p3, p4, p5, p6, p7) => { httpResponseHandlingDelegate(p1, p2, p3, p4, p5, p6, p7); }; AssetBundleListDownloader.AssetBundleListGetRequestHeaderDelegate assetBundleGetRequestHeaderDel = (p1, p2) => { return(assetBundleListGetRequestHeaderDelegate(p1, p2)); }; _assetBundleListDownloader = new AssetBundleListDownloader(assetBundleGetRequestHeaderDel, httpResponseHandlingDel); // check if assetBundleList are stored. var listCandidate = LoadAssetBundleListFromStorage(); if (!listCandidate.Exists()) { // no list stored. assetBundleFeatState = AssetBundlesFeatureState.None; return; } _currentAssetBundleList = listCandidate; assetBundleFeatState = AssetBundlesFeatureState.Ready; ReadyLoaderAndPreloader(); }
IEnumerator Start() { var LIST_DOWNLOAD_URL = "https://raw.githubusercontent.com/sassembla/Autoya/master/AssetBundles/main_assets/OSX/1.0.0/main_assets.json"; var ASSET_NAME = "Assets/AutoyaTests/RuntimeData/AssetBundles/MainResources/textureName.png"; // Download AssetBundle List from web. var listDownloader = new AssetBundleListDownloader(); AssetBundleList list = null; var cor = listDownloader.DownloadAssetBundleList( LIST_DOWNLOAD_URL, (url, newList) => { list = newList; }, (code, reason, status) => { Debug.LogError("list download error, code:" + code + " reason:" + reason); } ); while (cor.MoveNext()) { yield return(null); } // Load Asset from your AssetBundle. var loader = new AssetBundleLoader( bundleName => { var path = "https://raw.githubusercontent.com/sassembla/Autoya/master/AssetBundles/" + list.identity + "/" + list.target + "/" + list.version + "/"; return(path); } ); // set list to AssetBundleLoader. loader.UpdateAssetBundleList(list); var loadCor = loader.LoadAsset <Texture2D>( ASSET_NAME, (name, tex) => { Debug.Log("asset loaded! tex:" + tex); }, (name, error, reason, status) => { Debug.LogError("asset load failed. error:" + error + " reason:" + reason); } ); while (loadCor.MoveNext()) { yield return(null); } }
/* Initializer */ private void InitializeAssetBundleFeature() { // initialize AssetBundleListDownloader. AssetBundleListDownloader.HttpResponseHandlingDelegate httpResponseHandlingDel = (p1, p2, p3, p4, p5, p6, p7) => { httpResponseHandlingDelegate(p1, p2, p3, p4, p5, p6, p7); }; AssetBundleListDownloader.AssetBundleListGetRequestHeaderDelegate assetBundleGetRequestHeaderDel = (p1, p2) => { return assetBundleListGetRequestHeaderDelegate(p1, p2); }; /* by default, only list downloader is ready on boot in AssetBundles feature. */ _assetBundleListDownloader = new AssetBundleListDownloader(assetBundleGetRequestHeaderDel, httpResponseHandlingDel); // check if assetBundleList are stored. var storedLists = LoadAssetBundleListsFromStorage(); var storedListIdentities = storedLists.Select(list => list.identity).ToArray(); // get assetBundleList identitiy from manifest info. var runtimeManifestContaindAssetBundleListIdentities = LoadAppUsingAssetBundleListIdentities(); // 取得失敗などでmanifestの内容の方が多いことがあり得る。差を取り出し、DLが必要な状態かどうか判断する。 var excepts = runtimeManifestContaindAssetBundleListIdentities.Except(storedListIdentities); // not all assetBundleList are stored yet. // need to run AssetBundle_DownloadAssetBundleListsIfNeed(). if (excepts.Any()) { assetBundleFeatState = AssetBundlesFeatureState.None; return; } // all assetBundleList is stored and ready. foreach (var listCandidate in storedLists) { ReadyLoaderAndPreloader(listCandidate); } assetBundleFeatState = AssetBundlesFeatureState.Ready; }
public IEnumerator GetAssetBundleListFailed() { var listPath = abListPath + "FAKEPATH"; var loader = new AssetBundleListDownloader(); var done = false; yield return(loader.DownloadAssetBundleList( listPath, (downloadedUrl, list) => { True(false, "should not be succeeded."); }, (code, reason, autoyaStatus) => { True(code == 404, "error code does not match."); done = true; } )); yield return(WaitUntil( () => done, () => { throw new TimeoutException("not yet get assetBundleList."); } )); }
public IEnumerator GetAssetBundleList() { var listPath = abListPath + "1.0.0/main_assets.json"; var listDownloader = new AssetBundleListDownloader(); var done = false; yield return(listDownloader.DownloadAssetBundleList( listPath, (downloadedUrl, list) => { done = true; }, (code, reason, autoyaStatus) => { Fail("failed to get list." + code + " reason:" + reason); // do nothing. } )); yield return(WaitUntil( () => done, () => { throw new TimeoutException("not yet get assetBundleList."); } )); }
/* * Initializer */ private IEnumerator InitializeAssetBundleFeature() { this.assetBundleListGetRequestHeaderDelegate = OnAssetBundleListGetRequest; this.assetBundlePreloadListGetRequestHeaderDelegate = OnAssetBundlePreloadListGetRequest; this.assetBundleGetRequestHeaderDelegate = OnAssetBundleGetRequest; // initialize AssetBundleListDownloader. AssetBundleListDownloader.HttpResponseHandlingDelegate httpResponseHandlingDel = (p1, p2, p3, p4, p5, p6, p7) => { httpResponseHandlingDelegate(p1, p2, p3, p4, p5, p6, p7); }; AssetBundleListDownloader.AssetBundleListGetRequestHeaderDelegate assetBundleGetRequestHeaderDel = (p1, p2) => { return(assetBundleListGetRequestHeaderDelegate(p1, p2)); }; /* * by default, only list downloader is ready on boot in AssetBundles feature. */ _assetBundleListDownloader = new AssetBundleListDownloader(assetBundleGetRequestHeaderDel, httpResponseHandlingDel); // check if assetBundleList are stored. var storedLists = LoadAssetBundleListsFromStorage(); var storedListIdentities = storedLists.Select(list => list.identity).ToArray(); // get assetBundleList identitiy from manifest info. var runtimeManifestContaindAssetBundleListIdentities = LoadAppUsingAssetBundleListIdentities(); // remove unnecessary stored ABList if runtimeManifest is changed and ABListInfo is removed. { var storedMinusManifest = storedListIdentities.Except(runtimeManifestContaindAssetBundleListIdentities); if (storedMinusManifest.Any()) { OnRemoveUnnecessaryAssetBundleListsFromStorage(storedMinusManifest.ToArray()); // renew stored list identities. storedLists = LoadAssetBundleListsFromStorage(); storedListIdentities = storedLists.Select(list => list.identity).ToArray(); } } // check stored ABList. if less than required by RuntimeManifest, need to download additional ABList. { var manifestMinusStored = runtimeManifestContaindAssetBundleListIdentities.Except(storedListIdentities); // not all assetBundleList are stored yet. // need to run AssetBundle_DownloadAssetBundleListsIfNeed(). if (manifestMinusStored.Any()) { assetBundleFeatState = AssetBundlesFeatureState.None; yield break; } } // all assetBundleList is stored and ready. foreach (var listCandidate in storedLists) { ReadyLoaderAndPreloader(listCandidate); } assetBundleFeatState = AssetBundlesFeatureState.Ready; }