public static IEnumerator Dispose() { IsInitialising = true; for (int i = 0; i < Progress.GetCount(); i++) // Remove old progress { var progress = Progress.GetProgressById(Progress.GetId(i)); if (progress.finished && progress.name.Contains("Asset Bundles")) { progress.Remove(); } } 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 < Bundles.Count; i++) { Progress.Report(bundleID, (float)i / Bundles.Count, "Unloading: " + Bundles.ElementAt(i).Key); Bundles.ElementAt(i).Value.Unload(true); yield return(null); } int bundleCount = Bundles.Count; BundleLookup.Clear(); Bundles.Clear(); AssetCache.Clear(); Progress.Report(bundleID, 0.99f, "Unloaded: " + bundleCount + " bundles."); Progress.Finish(bundleID, Progress.Status.Succeeded); IsInitialised = false; IsInitialising = false; }