protected override IEnumerator runTest()
        {
            BundleMount bundleMount  = loadAndMount("DependencyBundlesTest/main.unity3d", null, isDependency: false);
            BundleMount bundleMount2 = loadAndMount("DependencyBundlesTest/dep1.unity3d", new HashSet <BundleMount> {
                bundleMount
            }, isDependency: true);
            BundleMount bundleMount3 = loadAndMount("DependencyBundlesTest/dep2.unity3d", new HashSet <BundleMount> {
                bundleMount2, bundleMount
            }, isDependency: true);

            bundleMount.IsPinned = true;
            IntegrationTest.Assert(bundleMount.IsPinned, "DependencyBundlesTest/main.unity3d");
            IntegrationTest.Assert(bundleMount2.IsPinned, "DependencyBundlesTest/dep1.unity3d");
            IntegrationTest.Assert(bundleMount3.IsPinned, "DependencyBundlesTest/dep2.unity3d");
            bundleMount.IsPinned = false;
            IntegrationTest.Assert(!bundleMount.IsPinned, "DependencyBundlesTest/main.unity3d");
            IntegrationTest.Assert(bundleMount2.IsPinned, "DependencyBundlesTest/dep1.unity3d");
            IntegrationTest.Assert(bundleMount3.IsPinned, "DependencyBundlesTest/dep2.unity3d");
            bundleMount3.IsPinned = true;
            IntegrationTest.Assert(!bundleMount.IsPinned, "DependencyBundlesTest/main.unity3d");
            IntegrationTest.Assert(bundleMount2.IsPinned, "DependencyBundlesTest/dep1.unity3d");
            IntegrationTest.Assert(bundleMount3.IsPinned, "DependencyBundlesTest/dep2.unity3d");
            bundleMount.Unload(unloadAllLoadedObjects: true);
            bundleMount2.Unload(unloadAllLoadedObjects: true);
            bundleMount3.Unload(unloadAllLoadedObjects: true);
            yield break;
        }
예제 #2
0
        protected override IEnumerator runTest()
        {
            string        key       = "embedded_asset_test";
            TextAsset     bundleTxt = Resources.Load <TextAsset>(key + ".unity3d");
            AssetBundle   bundle    = AssetBundle.LoadFromMemory(bundleTxt.bytes);
            BundleManager manager   = Content.BundleManager;
            BundleMount   mount     = manager.MountBundle(key, bundle);
            AsyncAssetBundleRequest <TextAsset> assetRequest = mount.LoadAsync <TextAsset>("embeddedasseta", "embeddedasseta.txt");

            manager.UnmountBundle(key, unloadAllLoadedObjects: false);
            if (manager.IsMounted(key))
            {
                IntegrationTest.Fail("Bundle should not be considered mounted while waiting to unmount.");
            }
            if (!manager.IsUnmounting(key))
            {
                IntegrationTest.Fail("Bundle should be in the process of unmounting.");
            }
            yield return(assetRequest);

            if (assetRequest.Asset == null)
            {
                IntegrationTest.Fail("Failed to load asset");
            }
            yield return(null);

            IntegrationTest.Assert(!manager.IsMounted(key));
            IntegrationTest.Assert(!manager.IsUnmounting(key));
        }
예제 #3
0
        protected override IEnumerator runTest()
        {
            string        key       = "embedded_asset_test";
            TextAsset     bundleTxt = Resources.Load <TextAsset>(key + ".unity3d");
            AssetBundle   bundle    = AssetBundle.LoadFromMemory(bundleTxt.bytes);
            BundleManager manager   = Content.BundleManager;
            BundleMount   mount     = manager.MountBundle(key, bundle);

            mount.IsPinned = true;
            if (!mount.IsPinned)
            {
                IntegrationTest.Fail("mount should be pinned");
            }
            yield return(new WaitForFrame(Math.Max(manager.UnmountFrameCount, manager.MonitorFrameFrequency) + 1));

            IntegrationTest.Assert(mount.IsMounted);
            IntegrationTest.Assert(manager.IsMounted(key));
            mount.Unload(unloadAllLoadedObjects: false);
        }
        private BundleMount loadAndMount(string key, HashSet <BundleMount> dependentMounts, bool isDependency)
        {
            if (dependentMounts == null)
            {
                dependentMounts = new HashSet <BundleMount>();
            }
            TextAsset   textAsset   = Resources.Load <TextAsset>(key);
            AssetBundle assetBundle = AssetBundle.LoadFromMemory(textAsset.bytes);
            BundleMount bundleMount = new BundleMount(assetBundle, key, dependentMounts);

            IntegrationTest.Assert(bundleMount.IsMounted, key);
            IntegrationTest.Assert(bundleMount.Key == key, key);
            IntegrationTest.Assert(bundleMount.DependentMounts == dependentMounts, key);
            IntegrationTest.Assert(bundleMount.ActiveRequestCount == 0, key);
            IntegrationTest.Assert(bundleMount.AssetCount == assetBundle.GetAllAssetNames().Length, key);
            IntegrationTest.Assert(bundleMount.Bundle == assetBundle, key);
            IntegrationTest.Assert(bundleMount.IsDependency == isDependency, key);
            IntegrationTest.Assert(bundleMount.IsPinned == isDependency, key);
            return(bundleMount);
        }
예제 #5
0
        protected override IEnumerator runTest()
        {
            string        key       = "embedded_asset_test";
            TextAsset     bundleTxt = Resources.Load <TextAsset>(key + ".unity3d");
            AssetBundle   bundle    = AssetBundle.LoadFromMemory(bundleTxt.bytes);
            BundleManager manager   = Content.BundleManager;
            BundleMount   mount     = manager.MountBundle(key, bundle);

            if (mount.IsPinned)
            {
                IntegrationTest.Fail("mount should not be pinned");
            }
            if (!mount.IsMounted)
            {
                IntegrationTest.Fail("mount should be mounted.");
            }
            while (mount.IsMounted || manager.IsMounted(key))
            {
                yield return(null);
            }
            IntegrationTest.Pass();
        }
예제 #6
0
        protected override IEnumerator runTest()
        {
            string      key       = "embedded_asset_test";
            TextAsset   bundleTxt = Resources.Load <TextAsset>(key + ".unity3d");
            AssetBundle bundle    = AssetBundle.LoadFromMemory(bundleTxt.bytes);
            BundleMount mount     = new BundleMount(bundle, "embedded_asset_test", null);

            if (mount.ActiveRequestCount != 0)
            {
                IntegrationTest.Fail("ActiveRequestCount should start at 0.");
            }
            AsyncAssetBundleRequest <TextAsset> requestA = mount.LoadAsync <TextAsset>("embeddedasseta", "embeddedasseta.txt");
            AsyncAssetBundleRequest <TextAsset> requestB = mount.LoadAsync <TextAsset>("embeddedasseta", "embeddedasseta.txt");

            if (mount.ActiveRequestCount != 1)
            {
                IntegrationTest.Fail("ActiveRequestCount should be at 1 after LoadAsync even if shared.");
            }
            bool finishedLoadingWasCalled = false;

            mount.EFinishedLoading += delegate
            {
                finishedLoadingWasCalled = true;
            };
            yield return(requestA);

            yield return(null);

            IntegrationTest.Assert(requestA == requestB);
            IntegrationTest.Assert(finishedLoadingWasCalled);
            TextAsset asset = requestA.Asset;

            IntegrationTest.Assert(asset != null);
            IntegrationTest.Assert(asset.text.StartsWith("embeddedasseta"));
            IntegrationTest.Assert(mount.ActiveRequestCount == 0);
            mount.Unload(unloadAllLoadedObjects: false);
        }
        protected override IEnumerator runTest()
        {
            string        text          = "embedded_asset_test";
            TextAsset     textAsset     = Resources.Load <TextAsset>(text + ".unity3d");
            AssetBundle   bundle        = AssetBundle.LoadFromMemory(textAsset.bytes);
            BundleManager bundleManager = Content.BundleManager;
            BundleMount   bundleMount   = bundleManager.MountBundle(text, bundle);

            IntegrationTest.Assert(bundleMount != null);
            bundle = bundleMount.Bundle;
            string[] allAssetNames = bundle.GetAllAssetNames();
            foreach (string text2 in allAssetNames)
            {
                Debug.LogWarningFormat("bundle asset {0}", text2);
            }
            IntegrationTest.Assert(bundle != null);
            IntegrationTest.Assert(bundle.GetAllAssetNames().Length == 2);
            IntegrationTest.Assert(bundle.Contains("assets/rootassets/embeddedasseta.txt"));
            IntegrationTest.Assert(bundle.Contains("assets/rootassets/embeddedassetb.txt"));
            IntegrationTest.Assert(bundleManager.IsMounted(text));
            bundleManager.UnmountBundle(text, unloadAllLoadedObjects: false);
            IntegrationTest.Assert(!bundleManager.IsMounted(text));
            yield break;
        }