static public AssetBundleLoadAllAssetsOperation LoadAssetBundleLoadAllAssetsAsync(string assetBundleName) { AssetBundleLoadAllAssetsOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { string[] assetBundlePaths = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName); if (assetBundlePaths.Length == 0) { ///@TODO: The error needs to differentiate that an asset bundle name doesn't exist // from that there right scene does not exist in the asset bundle... Debug.LogError("There is no asset bundle with name \"" + assetBundleName + "\""); return null; } operation = new AssetBundleLoadAllAssetsOperationSimulation(); } else #endif { LoadAssetBundle(assetBundleName); operation = new AssetBundleLoadAllAssetsOperationFull(assetBundleName); m_InProgressOperations.Add(operation); } return operation; }
protected IEnumerator LoadAssetBundleLoadAllAssets(string assetBundleName, Action <AssetBundle> callback) { Debug.Log("Start to load " + assetBundleName + " at frame " + Time.frameCount); AssetBundleLoadAllAssetsOperation request = AssetBundleManager.LoadAssetBundleLoadAllAssetsAsync(assetBundleName); if (request == null) { yield break; } yield return(StartCoroutine(request)); if (callback != null) { callback(request.GetAssetBundle()); } }
// Load asset from the given assetBundle. public AssetBundleLoadAllAssetsOperation LoadAllAssetsAsync(string a_assetBundleName, Type a_type) { if (string.IsNullOrEmpty(a_assetBundleName)) { return(null); } AssetBundleLoadAllAssetsOperation operation = null; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { var paths = AssetDatabase.GetAssetPathsFromAssetBundle(a_assetBundleName); var targets = new List <UnityEngine.Object>(paths.Length); for (int i = 0; i < paths.Length; ++i) { var path = paths[i]; var target = AssetDatabase.LoadAssetAtPath(path, a_type); targets.Add(target); paths[i] = path.ToLower(); } operation = new AssetBundleLoadAllAssetsOperationSimulation(paths, targets.ToArray()); } else #endif { var key = AllAssetsToKey(a_assetBundleName, a_type); AssetBundleLoadOperation inProgressOperation; if (m_inProgressOperationsByName.TryGetValue(key, out inProgressOperation)) { if (inProgressOperation is AssetBundleLoadAllAssetsOperation) { return(inProgressOperation as AssetBundleLoadAllAssetsOperation); } } LoadAssetBundle(a_assetBundleName); operation = new AssetBundleLoadAllAssetsOperationFull(a_assetBundleName, a_type); m_inProgressOperationsByName.Add(key, operation); m_inProgressOperations.Add(new KeyValuePair <string, AssetBundleLoadOperation>(key, operation)); } return(operation); }