示例#1
0
        /// <summary>
        /// ダウンロードサイズ取得
        /// </summary>
        /// <param name="assetBundleManager">アセットバンドルマネージャー</param>
        /// <returns>コルーチン</returns>
        protected IEnumerator DownloadSize(AssetBundleManager assetBundleManager)
        {
            Assert.IsTrue(assetBundleManager.ClearCache());
            assetBundleManager.SetVariants(new[] { "blue" });

            {
                var size = assetBundleManager.GetDownloadSize("AssetBundleShoshaTest/Primitive"
                                                              , "AssetBundleShoshaTest/ColorMaterials"
                                                              , "DeliveryStreamingAssets:AssetBundleShoshaTest/binary"
                                                              );
                Assert.Greater(size, 0);
            }

            {
                var size = assetBundleManager.GetDownloadSize("AssetBundleShoshaTest/Primitive");
                Assert.Greater(size, 0);
                var assetBundle = assetBundleManager.LoadAssetBundle("AssetBundleShoshaTest/Primitive");
                yield return(assetBundle);

                assetBundle.Dispose();
                size = assetBundleManager.GetDownloadSize("AssetBundleShoshaTest/Primitive");
                Assert.AreEqual(0, size);
            }

            {
                var size = assetBundleManager.GetDownloadSize("AssetBundleShoshaTest/ColorMaterials");
                Assert.Greater(size, 0);
                var assetBundle = assetBundleManager.LoadAssetBundle("AssetBundleShoshaTest/ColorMaterials");
                yield return(assetBundle);

                assetBundle.Dispose();
                size = assetBundleManager.GetDownloadSize("AssetBundleShoshaTest/ColorMaterials");
                Assert.AreEqual(0, size);
            }

            {
                var size = assetBundleManager.GetDownloadSize("DeliveryStreamingAssets:AssetBundleShoshaTest/binary");
                Assert.Greater(size, 0);
                var assetBundle = assetBundleManager.LoadAssetBundle("DeliveryStreamingAssets:AssetBundleShoshaTest/binary");
                yield return(assetBundle);

                assetBundle.Dispose();
                size = assetBundleManager.GetDownloadSize("DeliveryStreamingAssets:AssetBundleShoshaTest/binary");
                Assert.AreEqual(0, size);
            }

            var assetBundleNames = new List <string> {
                "AssetBundleShoshaTest/Primitive"
                , "AssetBundleShoshaTest/ColorMaterials"
                , "DeliveryStreamingAssets:AssetBundleShoshaTest/binary"
            };

            Assert.AreEqual(0, assetBundleManager.GetDownloadSize(assetBundleNames));

            assetBundleManager.SetVariants(null);
            yield break;
        }
示例#2
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());
        }