Example #1
0
        /// <summary>
        /// 全ダウンロード
        /// </summary>
        /// <param name="assetBundleManager">アセットバンドルマネージャー</param>
        /// <returns>コルーチン</returns>
        public IEnumerator DownloadAll(AssetBundleManager assetBundleManager)
        {
            Assert.IsTrue(assetBundleManager.ClearCache());
            assetBundleManager.SetVariants(new[] { "blue", "variant1" });

            System.Func <AssetBundleManager.DownloadAllAssetBundlesFlags, long> GetMissingSize = f => {
                var r = 0L;
                if ((f & AssetBundleManager.DownloadAllAssetBundlesFlags.ExcludeAssetBundles) == 0)
                {
                    r += assetBundleManager.GetDownloadSize("AssetBundleShoshaTest/MissingAssetBundle");
                }
                if ((f & AssetBundleManager.DownloadAllAssetBundlesFlags.ExcludeDeliveryStreamingAssets) == 0)
                {
                    r += assetBundleManager.GetDownloadSize("DeliveryStreamingAssets:AssetBundleShoshaTest/MissingDeliveryStreamingAssets");
                }
                return(r);
            };
            long missingSize;

            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/Primitive"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterialsCommon"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/CryptoAssetBundle"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/binary"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/DeliveryStreamingAssets"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(), 0);

            yield return(assetBundleManager.DownloadAllAssetBundles());

            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/Primitive"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterialsCommon"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/CryptoAssetBundle"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/binary"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/DeliveryStreamingAssets"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            missingSize = GetMissingSize(AssetBundleManager.DownloadAllAssetBundlesFlags.Null);
            Assert.AreEqual(missingSize, assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles());
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.IncludeOutOfVariants), missingSize);

            assetBundleManager.SetVariants(new[] { "red", "variant2" });

            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));

            Assert.IsTrue(assetBundleManager.ClearCache());
            assetBundleManager.SetVariants(new[] { "blue", "variant1" });

            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/Primitive"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterialsCommon"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/CryptoAssetBundle"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/binary"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/DeliveryStreamingAssets"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(), 0);

            yield return(assetBundleManager.DownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.ExcludeAssetBundles));

            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/Primitive"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterialsCommon"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/CryptoAssetBundle"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/binary"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/DeliveryStreamingAssets"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            missingSize = GetMissingSize(AssetBundleManager.DownloadAllAssetBundlesFlags.ExcludeAssetBundles);
            Assert.AreEqual(missingSize, assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.ExcludeAssetBundles));
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(), 0);
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.IncludeOutOfVariants), 0);

            Assert.IsTrue(assetBundleManager.ClearCache());
            assetBundleManager.SetVariants(new[] { "blue", "variant1" });

            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/Primitive"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterialsCommon"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/CryptoAssetBundle"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/binary"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/DeliveryStreamingAssets"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(), 0);

            yield return(assetBundleManager.DownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.ExcludeDeliveryStreamingAssets));

            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/Primitive"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterialsCommon"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/CryptoAssetBundle"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/binary"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/DeliveryStreamingAssets"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            missingSize = GetMissingSize(AssetBundleManager.DownloadAllAssetBundlesFlags.ExcludeDeliveryStreamingAssets);
            Assert.AreEqual(missingSize, assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.ExcludeDeliveryStreamingAssets));
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(), 0);
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.IncludeOutOfVariants), 0);

            Assert.IsTrue(assetBundleManager.ClearCache());
            assetBundleManager.SetVariants(new[] { "blue", "variant1" });

            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/Primitive"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterialsCommon"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsFalse(assetBundleManager.HasCache("AssetBundleShoshaTest/CryptoAssetBundle"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/binary"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/DeliveryStreamingAssets"));
            Assert.IsFalse(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            Assert.Greater(assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(), 0);

            yield return(assetBundleManager.DownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.IncludeOutOfVariants));

            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/Primitive"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterialsCommon"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/CryptoAssetBundle"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/binary"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/DeliveryStreamingAssets"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            missingSize = GetMissingSize(AssetBundleManager.DownloadAllAssetBundlesFlags.IncludeOutOfVariants);
            Assert.AreEqual(missingSize, assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.IncludeOutOfVariants));
            Assert.AreEqual(missingSize, assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles());

            assetBundleManager.SetVariants(new[] { "red", "variant2" });

            Assert.IsTrue(assetBundleManager.HasCache("AssetBundleShoshaTest/ColorMaterials"));
            Assert.IsTrue(assetBundleManager.HasCache("DeliveryStreamingAssets:AssetBundleShoshaTest/VariantStream"));
            missingSize = GetMissingSize(AssetBundleManager.DownloadAllAssetBundlesFlags.IncludeOutOfVariants);
            Assert.AreEqual(missingSize, assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles(AssetBundleManager.DownloadAllAssetBundlesFlags.IncludeOutOfVariants));
            Assert.AreEqual(missingSize, assetBundleManager.GetDownloadSizeByDownloadAllAssetBundles());
        }