// 异步加载资源包
 public void loadAssetBundleAsync(AssetBundleLoadCallback callback, object userData)
 {
     // 正在加载,则加入等待列表
     if (mLoadState == LOAD_STATE.LS_LOADING || mLoadState == LOAD_STATE.LS_WAIT_FOR_LOAD)
     {
         if (callback != null)
         {
             mLoadCallback.Add(callback);
         }
     }
     // 如果还未加载,则加载资源包,回调加入列表
     else if (mLoadState == LOAD_STATE.LS_UNLOAD)
     {
         if (callback != null)
         {
             mLoadCallback.Add(callback);
             mLoadUserData.Add(userData);
         }
         // 先确保所有依赖项已经加载
         loadParentAsync();
         mLoadState = LOAD_STATE.LS_WAIT_FOR_LOAD;
         // 通知AssetBundleLoader请求异步加载AssetBundle,只在真正开始异步加载时才标记为正在加载状态,此处只是加入等待列表
         mResourceManager.mAssetBundleLoader.requestLoadAssetBundle(this);
     }
     // 加载完毕,直接调用回调
     else if (mLoadState == LOAD_STATE.LS_LOADED)
     {
         callback?.Invoke(this, userData);
     }
 }
Example #2
0
 public void loadAssetBundleAsync(string bundleName, AssetBundleLoadCallback callback, object userData)
 {
     if (mLoadSource == LOAD_SOURCE.LS_RESOURCES)
     {
         // 从Resource加载不能加载AssetBundle
         callback?.Invoke(null, userData);
     }
     else if (mLoadSource == LOAD_SOURCE.LS_ASSET_BUNDLE)
     {
         mAssetBundleLoader.loadAssetBundleAsync(bundleName.ToLower(), callback, userData);
     }
 }
 // 异步加载资源包
 public void loadAssetBundleAsync(string bundleName, AssetBundleLoadCallback callback, object userData)
 {
     if (!mInited)
     {
         logError("AssetBundleLoader is not inited!");
         callback?.Invoke(null, userData);
         return;
     }
     if (mAssetBundleInfoList.ContainsKey(bundleName))
     {
         mAssetBundleInfoList[bundleName].loadAssetBundleAsync(callback, userData);
     }
     else
     {
         logError("can not find AssetBundle : " + bundleName);
     }
 }
 // 异步加载资源包
 public void loadAssetBundleAsync(string bundleName, AssetBundleLoadCallback callback, object userData = null)
 {
     if (!mInited)
     {
         logError("AssetBundleLoader is not inited!");
         callback?.Invoke(null, userData);
         return;
     }
     if (mAssetBundleInfoList.TryGetValue(bundleName, out AssetBundleInfo info))
     {
         info.loadAssetBundleAsync(callback, userData);
     }
     else
     {
         logError("can not find AssetBundle : " + bundleName);
     }
 }