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)); }
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); }