public static IEnumerator Dispose() { IsInitialising = true; ProgressManager.RemoveProgressBars("Unload Asset Bundles"); int progressID = Progress.Start("Unload Asset Bundles", null, Progress.Options.Sticky); int bundleID = Progress.Start("Bundles", null, Progress.Options.Sticky, progressID); int prefabID = Progress.Start("Prefabs", null, Progress.Options.Sticky, progressID); Progress.Report(bundleID, 0f); Progress.Report(prefabID, 0f); PrefabManager.ReplaceWithDefault(PrefabManager.CurrentMapPrefabs, prefabID); while (PrefabManager.IsChangingPrefabs) { yield return(null); } for (int i = 0; i < BundleCache.Count; i++) { Progress.Report(bundleID, (float)i / BundleCache.Count, "Unloading: " + BundleCache.ElementAt(i).Key); BundleCache.ElementAt(i).Value.Unload(true); yield return(null); } int bundleCount = BundleCache.Count; BundleLookup.Clear(); BundleCache.Clear(); AssetCache.Clear(); Progress.Report(bundleID, 0.99f, "Unloaded: " + bundleCount + " bundles."); Progress.Finish(bundleID, Progress.Status.Succeeded); IsInitialised = false; IsInitialising = false; }
private static T GetAsset <T>(string filePath) where T : Object { if (!BundleLookup.TryGetValue(filePath, out AssetBundle bundle)) { return(null); } return(bundle.LoadAsset <T>(filePath)); }
public void TryGetBundle_ReturnsFalse_WhenBundleIsNotRegistered(string bundleName) { var bundleLookup = new BundleLookup(_testBundles); var result = bundleLookup.TryGetBundle(bundleName, out Bundle bundle); Assert.False(result); Assert.Null(bundle); }
public void TryGetBundle_ReturnsValidBundle_WhenBundleIsRegistered(string bundleName) { var bundleLookup = new BundleLookup(_testBundles); var result = bundleLookup.TryGetBundle(bundleName, out Bundle bundle); Assert.True(result); Assert.NotNull(bundle); Assert.Equal(bundleName, bundle.Name); }
public void TryGetBundle_ThrowsException_WhenNameIsNull() { var bundleLookup = new BundleLookup(_testBundles); Assert.Throws <ArgumentNullException>(() => bundleLookup.TryGetBundle(null, out Bundle bundle)); }