From adb3c4f2ec9ff122ead80d146421f8046f818131 Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Fri, 27 Apr 2018 11:18:49 +1000 Subject: [PATCH 1/2] Public is Asset Bundle Loaded / Downloading --- AssetBundleManager/AssetBundleManager.cs | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/AssetBundleManager/AssetBundleManager.cs b/AssetBundleManager/AssetBundleManager.cs index 52763d7..b094e7d 100644 --- a/AssetBundleManager/AssetBundleManager.cs +++ b/AssetBundleManager/AssetBundleManager.cs @@ -359,6 +359,31 @@ public void UnloadBundle(string bundleName, bool unloadAllLoadedObjects, bool fo } } + /// + /// Returns if the Asset Bundle is already loaded + /// + public bool IsAssetBundleLoaded(string bundleName) + { + if (activeBundles.ContainsKey(bundleName)) { + return true; + } else { + return false; + } + } + + + /// + /// Returns if the Asset Bundle is already downloading + /// + public bool IsAssetBundleDownloading(string bundleName) + { + if (downloadsInProgress.ContainsKey(bundleName)){ + return true; + } else { + return false; + } + } + /// /// Caches the downloaded bundle and pushes it to the onComplete callback. /// From 08811158ed9e62c9ff8a08fd279e1f528c1efd11 Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Fri, 27 Apr 2018 11:31:32 +1000 Subject: [PATCH 2/2] Added overloaded method to return the bundle if it exists --- AssetBundleManager/AssetBundleManager.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/AssetBundleManager/AssetBundleManager.cs b/AssetBundleManager/AssetBundleManager.cs index b094e7d..572af23 100644 --- a/AssetBundleManager/AssetBundleManager.cs +++ b/AssetBundleManager/AssetBundleManager.cs @@ -371,13 +371,30 @@ public bool IsAssetBundleLoaded(string bundleName) } } + /// + /// Returns if the Asset Bundle is already loaded (out Bundle if loaded) + /// + public bool IsAssetBundleLoaded(string bundleName, out AssetBundle bundle) + { + AssetBundleContainer active; + if (activeBundles.TryGetValue(bundleName, out active)) + { + bundle = active.AssetBundle; + return true; + } + else + { + bundle = null; + return false; + } + } /// /// Returns if the Asset Bundle is already downloading /// public bool IsAssetBundleDownloading(string bundleName) { - if (downloadsInProgress.ContainsKey(bundleName)){ + if (downloadsInProgress.ContainsKey(bundleName)) { return true; } else { return false;