Exemplo n.º 1
0
        //ロードアセットバンドル
        IEnumerator LoadAssetBundleAsync(string path, Action onComplete, Action onFailed)
        {
            //path = DLCManager.AddParamVersionURL(path); // Glareでのバージョン管理番号をURLに追加.
            path = DLCManager.CreateDLCUrlForUtage(path);
            WWWEx wwwEx = MakeWWWEx(path);

            wwwEx.RetryCount = FileManager.AutoRetryCountOnDonwloadError;
            wwwEx.TimeOut    = FileManager.TimeOutDownload;

            this.AssetBundle = null;
            AssetBundle assetBundle = null;

            yield return(wwwEx.LoadAsync(
                             //OnComplete
                             (www) =>
            {
                if (Priority == AssetFileLoadPriority.DownloadOnly)
                {
                    www.assetBundle.Unload(true);
                    onComplete();
                }
                else
                {
                    assetBundle = www.assetBundle;
                    if (assetBundle == null)
                    {
                        SetLoadError(www.url + " is not assetBundle");
                        onFailed();
                    }
                }
            },
                             //OnFailed
                             (www) =>
            {
                //失敗
                onFailed();
            }
                             ));

            if (assetBundle != null)
            {
                yield return(LoadAssetBundleAsync(assetBundle, onComplete, onFailed));
            }
        }
        //アセットバンドルマニフェストをDLして情報を追加
        public IEnumerator DownloadManifestAsync(string rootUrl, string relativeUrl, Action onComplete, Action onFailed)
        {
            string url = FilePathUtil.Combine(rootUrl, relativeUrl);

            url = DLCManager.CreateDLCUrlForUtage(url);  //url = FilePathUtil.ToVersionManagerUrl(url);
            WWWEx wwwEx = new WWWEx(url);

            wwwEx.StoreBytes = true;
            wwwEx.OnUpdate   = OnDownloadingManifest;
            wwwEx.RetryCount = retryCount;
            wwwEx.TimeOut    = timeOut;
//			Debug.Log("Load Start " + url);
            return(wwwEx.LoadAssetBundleByNameAsync <AssetBundleManifest>(
                       AssetBundleManifestName,
                       false,
                       (manifest) =>
            {
                AddAssetBundleManifest(rootUrl, manifest);
                if (UseCacheManifest)
                {
                    string path = GetCachePath(relativeUrl);
                    FileIOManager.CreateDirectory(FilePathUtil.GetDirectoryPath(path) + "/");
                    FileIOManager.Write(path, wwwEx.Bytes);
                }
                if (onComplete != null)
                {
                    onComplete();
                }
            },
                       () =>
            {
                if (onFailed != null)
                {
                    onFailed();
                }
            }
                       ));
        }