Exemple #1
0
    public IEnumerator StoredAssetBundleListIsEmptyOnBoot()
    {
        // 事前に保存済みのデータを消す、これでほかのテストの影響を受けない初期化されたデータだけができる。
        Autoya.Persist_DeleteByDomain(AppSettings.APP_STORED_RUNTIME_MANIFEST_DOMAIN);
        Autoya.Persist_DeleteByDomain(AssetBundlesSettings.ASSETBUNDLES_LIST_STORED_DOMAIN);

        var dataPath = Application.persistentDataPath;

        Autoya.TestEntryPoint(dataPath);
        {
            var loginDone = false;
            Autoya.Auth_SetOnAuthenticated(
                () =>
            {
                loginDone = true;
            }
                );

            yield return(WaitUntil(
                             () =>
            {
                return loginDone;
            },
                             () => { throw new TimeoutException("timeout."); }
                             ));
        }

        Assert.True(!Autoya.AssetBundle_IsAssetBundleFeatureReady(), "ready.");
    }
    IEnumerator InstanciatePrefab(string prefabName, Vector3 position)
    {
        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(status => { }, (code, reason, autoyaStatus) => { });

        // wait downloading assetBundleList.
        while (!Autoya.AssetBundle_IsAssetBundleFeatureReady())
        {
            yield return(null);
        }

        Autoya.AssetBundle_LoadAsset <GameObject>(
            prefabName,
            (assetName, prefab) =>
        {
            Debug.Log("asset:" + assetName + " is successfully loaded as:" + prefab);

            // instantiate asset.
            Instantiate(prefab, position, Quaternion.identity);
        },
            (assetName, err, reason, status) =>
        {
            Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason);
        }
            );
    }
Exemple #3
0
    public IEnumerator Teardown()
    {
        var discarded = false;

        // delete assetBundleList anyway.
        Autoya.AssetBundle_DiscardAssetBundleList(
            () =>
        {
            discarded = true;
        },
            (code, reason) =>
        {
            Fail("code:" + code + " reason:" + reason);
        }
            );

        yield return(WaitUntil(
                         () => discarded,
                         () => { throw new TimeoutException("too late."); }
                         ));

        var listExists = Autoya.AssetBundle_IsAssetBundleFeatureReady();

        True(!listExists, "exists, not intended.");
    }
Exemple #4
0
    public IEnumerator PreloadAssetBundleBeforeGetAssetBundleListWillFail()
    {
        True(!Autoya.AssetBundle_IsAssetBundleFeatureReady(), "not match.");

        var done = false;

        Autoya.AssetBundle_Preload(
            "1.0.0/sample.preloadList.json",
            (willLoadBundleNames, proceed, cancel) =>
        {
            proceed();
        },
            progress =>
        {
        },
            () =>
        {
            Fail("should not be succeeded.");
        },
            (code, reason, autoyaStatus) =>
        {
            True(code == -(int)Autoya.AssetBundlesError.NeedToDownloadAssetBundleList, "not match. code:" + code + " reason:" + reason);
            done = true;
        },
            (failedAssetBundleName, code, reason, autoyaStatus) =>
        {
        },
            1
            );

        yield return(WaitUntil(
                         () => done,
                         () => { throw new TimeoutException("not yet done."); }
                         ));
    }
Exemple #5
0
    public IEnumerator Teardown()
    {
        Autoya.AssetBundle_UnloadOnMemoryAssetBundles();


        var discarded = false;

        // delete assetBundleList anyway.
        Autoya.AssetBundle_DiscardAssetBundleList(
            () =>
        {
            discarded = true;
        },
            (code, reason) =>
        {
            switch (code)
            {
            case Autoya.AssetBundlesError.NeedToDownloadAssetBundleList:
                {
                    discarded = true;
                    break;
                }

            default:
                {
                    Fail("code:" + code + " reason:" + reason);
                    break;
                }
            }
        }
            );

        yield return(WaitUntil(
                         () => discarded,
                         () => { throw new TimeoutException("too late."); }
                         ));

        var listExists = Autoya.AssetBundle_IsAssetBundleFeatureReady();

        True(!listExists, "exists, not intended.");

        True(Caching.CleanCache());
    }
Exemple #6
0
    // 特定のjsonで記述された「アセットバンドル情報をまとめたリスト」をダウンロードするサンプル
    //
    IEnumerator Start()
    {
        /*
         *  this is sample of "preload assetBundles feature".
         *  the word "preload" in this sample means "download assetBundles without use."
         *  preloaded assetBundles are stored in storage cache. no difference between preloaded and downloaded assetBundles.
         *  case2:get preloadList from web, then get described assetBundles.
         */

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(status => { }, (code, reason, autoyaStatus) => { });

        // wait downloading assetBundleList.
        while (!Autoya.AssetBundle_IsAssetBundleFeatureReady())
        {
            yield return(null);
        }

        var assetBundleLists = Autoya.AssetBundle_AssetBundleLists();

        // create sample preloadList which contains all assetBundle names in assetBundleList.
        var assetBundleNames = assetBundleLists.SelectMany(list => list.assetBundles).Select(abInfo => abInfo.bundleName).ToArray();
        var newPreloadList   = new PreloadList("samplePreloadList", assetBundleNames);

        Autoya.AssetBundle_PreloadByList(
            newPreloadList,
            (willLoadBundleNames, proceed, cancel) =>
        {
            proceed();
        },
            progress =>
        {
            Debug.Log("progress:" + progress);
        },
            () =>
        {
            Debug.Log("preloading all listed assetBundles is finished.");

            // then, you can use these assetBundles immediately. without any downloading.
            Autoya.AssetBundle_LoadAsset <GameObject>(
                "Assets/Demo/____ASSET_BUNDLES/unitychan_std/Prefabs/UnityChan_Std.prefab",
                (assetName, prefab) =>
            {
                Debug.Log("asset:" + assetName + " is successfully loaded as:" + prefab);

                // instantiate asset.
                Instantiate(prefab);
            },
                (assetName, err, reason, status) =>
            {
                Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason);
            }
                );

            Autoya.AssetBundle_LoadAsset <GameObject>(
                "Assets/Demo/____ASSET_BUNDLES/unitychan_crs/Prefabs/UnityChan_Crs.prefab",
                (assetName, prefab) =>
            {
                Debug.Log("asset:" + assetName + " is successfully loaded as:" + prefab);

                // instantiate asset.
                Instantiate(prefab, new Vector3(1f, 0, 0), Quaternion.identity);
            },
                (assetName, err, reason, status) =>
            {
                Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason);
            }
                );
        },
            (code, reason, autoyaStatus) =>
        {
            Debug.LogError("preload failed. code:" + code + " reason:" + reason);
        },
            (downloadFailedAssetBundleName, code, reason, autoyaStatus) =>
        {
            Debug.LogError("failed to preload assetBundle:" + downloadFailedAssetBundleName + ". code:" + code + " reason:" + reason);
        },
            10 // 10 parallel download! you can set more than 0.
            );
    }
    // Use this for initialization
    IEnumerator Start()
    {
        // need to wait finish authentication.
        while (!Autoya.Auth_IsAuthenticated())
        {
            yield return(null);
        }

        /*
         *              this is sample of "preload assetBundles feature".
         *
         *              the word "preload" in this sample means "download assetBundles without use."
         *              preloaded assetBundles are stored in storage cache. no difference between preloaded and downloaded assetBundles.
         *
         *              case1:generate preloadList from assetBundleList, then get described assetBundles.
         */

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(status => { }, (code, reason, autoyaStatus) => { });

        // wait downloading assetBundleList.
        while (!Autoya.AssetBundle_IsAssetBundleFeatureReady())
        {
            yield return(null);
        }


        /*
         *              let's preload specific assetBundle into device storage.
         */

        // get assetBundleList.
        var assetBundleLists = Autoya.AssetBundle_AssetBundleLists();

        // create sample preloadList which contains all assetBundle names in assetBundleList.
        var assetBundleNames = assetBundleLists.SelectMany(list => list.assetBundles).Select(abInfo => abInfo.bundleName).ToArray();
        var newPreloadList   = new PreloadList("samplePreloadList", assetBundleNames);

        Autoya.AssetBundle_PreloadByList(
            newPreloadList,
            (willLoadBundleNames, proceed, cancel) =>
        {
            proceed();
        },
            progress =>
        {
            Debug.Log("progress:" + progress);
        },
            () =>
        {
            Debug.Log("preloading all listed assetBundles is finished.");

            // then, you can use these assetBundles immediately. without any downloading.
            Autoya.AssetBundle_LoadAsset <GameObject>(
                "Assets/AutoyaTests/RuntimeData/AssetBundles/MainResources/textureName1.prefab",
                (assetName, prefab) =>
            {
                Debug.Log("asset:" + assetName + " is successfully loaded as:" + prefab);

                // instantiate asset.
                Instantiate(prefab);
            },
                (assetName, err, reason, status) =>
            {
                Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason);
            }
                );
        },
            (code, reason, autoyaStatus) =>
        {
            Debug.LogError("preload failed. code:" + code + " reason:" + reason);
        },
            (downloadFailedAssetBundleName, code, reason, autoyaStatus) =>
        {
            Debug.LogError("failed to preload assetBundle:" + downloadFailedAssetBundleName + ". code:" + code + " reason:" + reason);
        },
            10 // 10 parallel download! you can set more than 0.
            );
    }
Exemple #8
0
    public IEnumerator StoredAssetBundleListIsEnoughOnBoot()
    {
        // 事前に保存済みのデータを消す、これでほかのテストの影響を受けない初期化されたデータだけができる。
        Autoya.Persist_DeleteByDomain(AppSettings.APP_STORED_RUNTIME_MANIFEST_DOMAIN);
        Autoya.Persist_DeleteByDomain(AssetBundlesSettings.ASSETBUNDLES_LIST_STORED_DOMAIN);

        var dataPath = Application.persistentDataPath;

        Autoya.TestEntryPoint(dataPath);
        {
            var loginDone = false;
            Autoya.Auth_SetOnAuthenticated(
                () =>
            {
                loginDone = true;
            }
                );

            yield return(WaitUntil(
                             () =>
            {
                return loginDone;
            },
                             () => { throw new TimeoutException("timeout."); }
                             ));
        }

        var abReady = false;

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(
            results =>
        {
            abReady = true;
        },
            (code, reason, status) =>
        {
            Debug.LogError("failed to download ABList, code:" + code + " reason:" + reason);
        }
            );
        while (!abReady)
        {
            yield return(null);
        }

        // reboot autoya.
        Autoya.TestEntryPoint(dataPath);

        {
            var loginDone = false;
            Autoya.Auth_SetOnAuthenticated(
                () =>
            {
                loginDone = true;
            }
                );

            yield return(WaitUntil(
                             () =>
            {
                return loginDone;
            },
                             () => { throw new TimeoutException("timeout."); }
                             ));
        }

        Assert.True(Autoya.AssetBundle_IsAssetBundleFeatureReady(), "not ready.");
    }
    // Use this for initialization
    IEnumerator Start()
    {
        // need to wait finish authentication.
        while (!Autoya.Auth_IsAuthenticated())
        {
            yield return(null);
        }

        /*
         *              this is sample of "preload assetBundles feature".
         *
         *              the word "preload" in this sample means "download assetBundles without use."
         *              preloaded assetBundles are stored in storage cache. no difference between preloaded and downloaded assetBundles.
         *
         *              case2:get preloadList from web, then get described assetBundles.
         */

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(status => { }, (code, reason, autoyaStatus) => { });

        // wait downloading assetBundleList.
        while (!Autoya.AssetBundle_IsAssetBundleFeatureReady())
        {
            yield return(null);
        }

        /*
         *              get preloadList from web.
         *              the base filePath settings is located at AssetBundlesSettings.ASSETBUNDLES_URL_DOWNLOAD_PRELOADLIST.
         *
         *              this preloadList contains 1 assetBundleName, "bundlename", contains 1 asset, "textureName.png"
         *
         *              note that:
         *                      this feature requires the condition:"assetBundleList is stored." for getting assetBundleInfo. (crc, hash, and dependencies.)
         */

        var preloadListPath = "sample.preloadList.json";

        // this will become ASSETBUNDLES_URL_DOWNLOAD_PRELOADLIST + sample.preloadList.json.


        // download preloadList from web then preload described assetBundles.
        Autoya.AssetBundle_Preload(
            preloadListPath,
            (willLoadBundleNames, proceed, cancel) =>
        {
            var totalWeight = Autoya.AssetBundle_GetAssetBundlesWeight(willLoadBundleNames);
            Debug.Log("start downloading bundles. total weight:" + totalWeight);

            proceed();
        },
            progress =>
        {
            Debug.Log("progress:" + progress);
        },
            () =>
        {
            Debug.Log("preloading 1 listed assetBundles is finished.");

            // then, you can use these assetBundles immediately. without any downloading.
            Autoya.AssetBundle_LoadAsset <Texture2D>(
                "Assets/AutoyaTests/RuntimeData/AssetBundles/MainResources/textureName.png",
                (assetName, image) =>
            {
                Debug.Log("asset:" + assetName + " is successfully loaded as:" + image);

                // create gameObject, then set tex to it as sprite.
                var gameObj           = new GameObject("createdGameObject");
                var imageComponent    = gameObj.AddComponent <Image>();
                imageComponent.sprite = Sprite.Create(image, new Rect(0.0f, 0.0f, image.width, image.height), new Vector2(0.5f, 0.5f), 100.0f);

                // find uGUI canvas then set.
                var canvas = GameObject.Find("Canvas");
                gameObj.transform.SetParent(canvas.transform, false);
            },
                (assetName, err, reason, status) =>
            {
                Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason);
            }
                );
        },
            (code, reason, autoyaStatus) =>
        {
            Debug.LogError("preload failed. code:" + code + " reason:" + reason);
        },
            (downloadFailedAssetBundleName, code, reason, autoyaStatus) =>
        {
            Debug.LogError("failed to preload assetBundle:" + downloadFailedAssetBundleName + ". code:" + code + " reason:" + reason);
        },
            10 // 10 parallel download! you can set more than 0.
            );
    }
Exemple #10
0
    IEnumerator DownloadBySpecificJsonListNameCoroutine(string jsonListName)
    {
        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(status => { }, (code, reason, autoyaStatus) => { });

        // wait downloading assetBundleList.
        while (!Autoya.AssetBundle_IsAssetBundleFeatureReady())
        {
            yield return(null);
        }


        //使わないけど、インターネット上のフルパスは何か、を表示しておく
        var fullPathForJsonListURL = AutoyaFramework.Settings.AssetBundles.AssetBundlesSettings.ASSETBUNDLES_URL_DOWNLOAD_PRELOADLIST + jsonListName;

        Debug.Log("このURLのjsonに書いてある未キャッシュのアセットバンドルを全部ダウンロードします" + fullPathForJsonListURL);

        //memo:
        //この処理で気を付ける点として、fullPathForJsonListURLのURLを直接ブラウザで見てみると、アセットバンドルの「名前だけ」がjsonのリストに含まれています
        //では個別URLとか、CRCとか、バージョン情報とかは無いのに、なんで名前だけでダウンロード出来てしまうのかと言うと
        //Autoyaでは既にアセットバンドルをビルドした時の後処理として、これら個別URL,CRCなどの塊をキャッシュで保持してくれる仕組みがあります。
        //Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(status => { }, (code, reason, autoyaStatus) => { });
        //↑これがその処理です。内部では色々な事をしていますが、あまり意識しなくてもおまじないとして使えるようになっています。
        //ただし、気を付ける点としてAutoyaのレールを外れる(例えばアセットバンドルだけを別プロジェクトで運用する、あるいは自前でバージョン処理を書く、設定ファイルの記載を無視して自前で挙動やURLを指定する)
        //と、一気に考えることが増えます。それはお勧めしません。

        // download preloadList from web then preload described assetBundles.
        Autoya.AssetBundle_Preload(
            jsonListName,
            (willLoadBundleNames, proceed, cancel) =>
        {
            //ここで、(ダウンロード予定のリストは取得した後、アセットバンドルのダウンロードを始める直前の処理を差し込めます
            //ユースケースとしては「〇〇バイトのダウンロードを行います。よろしいですか?」みたいな感じです。
            var totalWeight = Autoya.AssetBundle_GetAssetBundlesWeight(willLoadBundleNames);

            //もし、ダウンロード済だったらダイアログを出さずにさっさとこの関数を抜けたい。という場合は以下のように書いてください

            /*
             * if (totalWeight < 1)
             * {
             *  proceed();
             * }
             */
            Debug.Log(jsonListName + ":------will loading---------" + totalWeight + " byte");
            foreach (var item in willLoadBundleNames)
            {
                Debug.Log(item);
            }
            //ダイアログを出して、ダウンロードして良いか聞く。これは便利…
            Dialog.Show(new UnityEngine.Events.UnityAction(proceed), new UnityEngine.Events.UnityAction(cancel), totalWeight + "バイトのダウンロードを行います。良いですか");
            Debug.Log("------end------");
        },
            progress =>
        {
            //アセットバンドルのダウンロードが一個終わる度にここが呼び出され、progressの値が0から1に増えていきます。
            //大変残念ですが、ダウンロードすべきアセットバンドルが1個だけの場合は、このprogressは1だけになります。
            //なぜかというと1個づつアセットバンドルがダウンロード完了した毎に、Autoyaはprogressのイベントを発火するためです。
            //こういう小さなデモアプリだと1しか出なくて不便だ…と思われるかもしれませんが、実際の運用では問題ないです。
            Debug.Log("progress:" + progress);
        },
            () =>
        {
            //ここでダウンロードが全部終わった、あるいは全部キャッシュ済みだった時の処理を書く
            //Instanciateするとか、実際に使うシーンに遷移するとか
            //一応今回はメインで使うシーンに遷移、というパターンのデモアプリにしています。
            Debug.Log("preloading all listed assetBundles is finished.");

            //もし、ダウンロード直後にInstanciateしたい、とかなら、以下のように書きます

            /*
             * Autoya.AssetBundle_LoadAsset<GameObject>(
             * "Assets/Demo/____ASSET_BUNDLES/unitychan_crs/Prefabs/UnityChan_Crs.prefab",
             * (assetName, prefab) =>
             * {
             *     Debug.Log("asset:" + assetName + " is successfully loaded as:" + prefab);
             *
             *     // instantiate asset.
             *     Instantiate(prefab, new Vector3(1f, 0, 0), Quaternion.identity);
             * },
             * (assetName, err, reason, status) =>
             * {
             *     Debug.LogError("failed to load assetName:" + assetName + " err:" + err + " reason:" + reason);
             * }
             * );
             */
        },
            (code, reason, autoyaStatus) =>
        {
            Debug.LogError("preload failed. code:" + code + " reason:" + reason);
        },
            (downloadFailedAssetBundleName, code, reason, autoyaStatus) =>
        {
            Debug.LogError("failed to preload assetBundle:" + downloadFailedAssetBundleName + ". code:" + code + " reason:" + reason);
        },
            10 // 10 parallel download! you can set more than 0.
            );
    }
Exemple #11
0
    public IEnumerator UpdateListWithOnMemoryAssetsThenPreloadLoadedChangedAsset()
    {
        var done = false;

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(
            status =>
        {
            done = true;
        },
            (code, reason, asutoyaStatus) =>
        {
            Fail("UpdateListWithOnMemoryAssets failed, code:" + code + " reason:" + reason);
        }
            );

        yield return(WaitUntil(
                         () => done,
                         () => { throw new TimeoutException("faild to get assetBundleList."); }
                         ));

        True(Autoya.AssetBundle_IsAssetBundleFeatureReady());


        UnityEngine.Object[] loadedAssets = null;

        // 全てのABをロード
        yield return(LoadAllAssetBundlesOfMainAssets(objs => { loadedAssets = objs; }));

        True(loadedAssets != null);
        // var guids = loadedAssets.Select(a => a.GetInstanceID()).ToArray();

        var loadedAssetBundleNames = Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().assetBundles.Select(a => a.bundleName).ToArray();

        // 1.0.1 リストの更新判断の関数をセット
        var listContainsUsingAssetsAndShouldBeUpdate = false;

        Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList(
            (basePath, identity, ver) =>
        {
            var url = basePath + identity + "/" + AssetBundlesSettings.PLATFORM_STR + "/" + ver + "/" + identity + ".json";
            return(Autoya.ShouldRequestOrNot.Yes(url));
        }
            );

        Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList(
            condition =>
        {
            if (condition == Autoya.CurrentUsingBundleCondition.UsingAssetsAreChanged)
            {
                listContainsUsingAssetsAndShouldBeUpdate = true;
            }
            return(true);
        }
            );



        // 1.0.1リストを取得
        Autoya.Http_Get(
            "https://httpbin.org/response-headers?" + AuthSettings.AUTH_RESPONSEHEADER_RESVERSION + "=main_assets:1.0.1",
            (conId, data) =>
        {
            // pass.
        },
            (conId, code, reason, status) =>
        {
            Fail();
        }
            );

        yield return(WaitUntil(
                         () => listContainsUsingAssetsAndShouldBeUpdate,
                         () => { throw new TimeoutException("failed to get response."); },
                         10
                         ));

        True(Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().version == "1.0.1");


        // preload all.
        var preloadDone = false;

        var preloadList = new PreloadList("dummy", loadedAssetBundleNames);

        Autoya.AssetBundle_PreloadByList(
            preloadList,
            (preloadCandidateBundleNames, go, stop) =>
        {
            // all assetBundles should not be download. on memory loaded ABs are not updatable.
            True(preloadCandidateBundleNames.Length == 0);
            go();
        },
            progress => { },
            () =>
        {
            preloadDone = true;
        },
            (code, reason, status) =>
        {
            Fail("code:" + code + " reason:" + reason);
        },
            (failedAssetBundleName, code, reason, status) =>
        {
            Fail("failedAssetBundleName:" + failedAssetBundleName + " code:" + code + " reason:" + reason);
        },
            5
            );

        yield return(WaitUntil(
                         () => preloadDone,
                         () => { throw new TimeoutException("failed to preload."); },
                         10
                         ));
    }
Exemple #12
0
    public IEnumerator UpdateListWithOnMemoryAssetsThenReloadChangedAsset()
    {
        var done = false;

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(
            status =>
        {
            done = true;
        },
            (code, reason, asutoyaStatus) =>
        {
            Fail("UpdateListWithOnMemoryAssets failed, code:" + code + " reason:" + reason);
        }
            );

        yield return(WaitUntil(
                         () => done,
                         () => { throw new TimeoutException("faild to get assetBundleList."); }
                         ));

        True(Autoya.AssetBundle_IsAssetBundleFeatureReady());


        UnityEngine.Object[] loadedAssets = null;

        // 全てのABをロード
        yield return(LoadAllAssetBundlesOfMainAssets(objs => { loadedAssets = objs; }));

        True(loadedAssets != null);

        var guidsDict = loadedAssets.ToDictionary(
            a => a.name,
            a => a.GetInstanceID()
            );

        // 1.0.1 リストの更新判断の関数をセット
        var listContainsUsingAssetsAndShouldBeUpdate = false;

        Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList(
            (basePath, identity, ver) =>
        {
            var url = basePath + identity + "/" + AssetBundlesSettings.PLATFORM_STR + "/" + ver + "/" + identity + ".json";
            return(Autoya.ShouldRequestOrNot.Yes(url));
        }
            );

        Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList(
            condition =>
        {
            if (condition == Autoya.CurrentUsingBundleCondition.UsingAssetsAreChanged)
            {
                listContainsUsingAssetsAndShouldBeUpdate = true;
            }
            return(true);
        }
            );



        // 1.0.1リストを取得
        Autoya.Http_Get(
            "https://httpbin.org/response-headers?" + AuthSettings.AUTH_RESPONSEHEADER_RESVERSION + "=main_assets:1.0.1",
            (conId, data) =>
        {
            // pass.
        },
            (conId, code, reason, status) =>
        {
            Fail("code:" + code + " reason:" + reason);
        }
            );

        yield return(WaitUntil(
                         () => listContainsUsingAssetsAndShouldBeUpdate,
                         () => { throw new TimeoutException("failed to get response."); },
                         10
                         ));

        True(Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().version == "1.0.1");

        // 再度ロード済みのAssetをLoadしようとすると、更新があったABについて最新を取得してくる。

        UnityEngine.Object[] loadedAssets2 = null;
        yield return(LoadAllAssetBundlesOfMainAssets(objs => { loadedAssets2 = objs; }));

        var newGuidsDict = loadedAssets2.ToDictionary(
            a => a.name,
            a => a.GetInstanceID()
            );

        var changedAssetCount = 0;

        foreach (var newGuidItem in newGuidsDict)
        {
            var name = newGuidItem.Key;
            var guid = newGuidItem.Value;
            if (guidsDict[name] != guid)
            {
                changedAssetCount++;
            }
        }
        True(changedAssetCount == 1);
    }
Exemple #13
0
    public IEnumerator UpdateListWithOnMemoryAssets()
    {
        var done = false;

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(
            status =>
        {
            done = true;
        },
            (code, reason, asutoyaStatus) =>
        {
            Fail("UpdateListWithOnMemoryAssets failed, code:" + code + " reason:" + reason);
        }
            );

        yield return(WaitUntil(
                         () => done,
                         () => { throw new TimeoutException("faild to get assetBundleList."); }
                         ));

        True(Autoya.AssetBundle_IsAssetBundleFeatureReady());


        UnityEngine.Object[] loadedAssets = null;

        // 全てのABをロード
        yield return(LoadAllAssetBundlesOfMainAssets(objs => { loadedAssets = objs; }));

        True(loadedAssets != null);

        // 1.0.1 リストの更新判断の関数をセット
        var listContainsUsingAssetsAndShouldBeUpdate = false;

        Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList(
            (basePath, identity, ver) =>
        {
            var url = basePath + identity + "/" + AssetBundlesSettings.PLATFORM_STR + "/" + ver + "/" + identity + ".json";
            return(Autoya.ShouldRequestOrNot.Yes(url));
        }
            );

        Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList(
            condition =>
        {
            if (condition == Autoya.CurrentUsingBundleCondition.UsingAssetsAreChanged)
            {
                listContainsUsingAssetsAndShouldBeUpdate = true;
            }
            return(true);
        }
            );



        // 1.0.1リストを取得
        Autoya.Http_Get(
            "https://httpbin.org/response-headers?" + AuthSettings.AUTH_RESPONSEHEADER_RESVERSION + "=main_assets:1.0.1",
            (conId, data) =>
        {
            // pass.
        },
            (conId, code, reason, status) =>
        {
            Fail();
        }
            );

        yield return(WaitUntil(
                         () => listContainsUsingAssetsAndShouldBeUpdate,
                         () => { throw new TimeoutException("failed to get response."); },
                         10
                         ));

        True(Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().version == "1.0.1");

        // load状態のAssetはそのまま使用できる
        for (var i = 0; i < loadedAssets.Length; i++)
        {
            var loadedAsset = loadedAssets[i];
            True(loadedAsset != null);
        }
    }