示例#1
0
 // 异步加载指定的资源包
 public void loadPathOrBundleAsync(string path, AssetBundleLoadDoneCallback callback)
 {
     if (mLoadSource == 0)
     {
         mResourceLoader.loadPathAsync(path, callback);
     }
     else if (mLoadSource == 1)
     {
         mAssetBundleLoader.loadAssetBundleAsync(path, callback);
     }
 }
示例#2
0
 // 异步加载整个文件夹
 public void loadPathAsync(string path, AssetBundleLoadDoneCallback callback)
 {
     if (mLoadedPath.ContainsKey(path))
     {
         callback(new List <UnityEngine.Object>(mLoadedPath[path].Values));
     }
     else
     {
         mLoadedPath.Add(path, new Dictionary <string, UnityEngine.Object>());
         StartCoroutine(loadPathCoroutine(path, callback));
     }
 }
示例#3
0
 // 异步加载资源包
 public void loadAssetBundleAsync(AssetBundleLoadDoneCallback callback)
 {
     if (mLoaded != LOAD_STATE.LS_UNLOAD)
     {
         return;
     }
     // 先确保所有依赖项已经加载
     foreach (var info in mParents)
     {
         info.Value.loadAssetBundleAsync(null);
     }
     // 通知AssetBundleLoader请求异步加载AssetBundle
     mLoaded = LOAD_STATE.LS_LOADING;
     mResourceManager.mAssetBundleLoader.requestLoadAssetBundle(this);
     mAssetBundleLoadCallback = callback;
 }
示例#4
0
    // 异步加载资源包
    public bool loadAssetBundleAsync(string bundleName, AssetBundleLoadDoneCallback doneCallback)
    {
        if (!mAssetBundleInfoList.ContainsKey(bundleName))
        {
            return(false);
        }
        AssetBundleInfo bundleInfo = mAssetBundleInfoList[bundleName];

        if (bundleInfo.mLoaded != LOAD_STATE.LS_UNLOAD)
        {
            UnityUtility.logError("asset bundle is loading or loaded, can not load again! name : " + bundleName);
            return(false);
        }
        // 加载资源包
        bundleInfo.loadAssetBundleAsync(doneCallback);
        return(true);
    }
示例#5
0
    protected IEnumerator loadPathCoroutine(string path, AssetBundleLoadDoneCallback callback)
    {
        // 查找文件夹
        List <string> fileList = new List <string>();

        FileUtility.findFiles(path, ref fileList, null);
        int fileCount = fileList.Count;
        List <UnityEngine.Object> resList = new List <UnityEngine.Object>();

        for (int i = 0; i < fileCount; ++i)
        {
            if (fileList[i].EndsWith(".meta"))
            {
                continue;
            }
            ResourceRequest assetRequest = Resources.LoadAsync(path + "/" + fileList[i]);
            yield return(assetRequest);

            mLoadedPath[path].Add(path + "/" + fileList[i], assetRequest.asset);
        }
        callback(resList);
    }