/// <summary> /// 异步加载资源 /// handlerFinish:结束回调 /// </summary> public void loadAssetAsync(string strAssetPath, task.TaskBase.FinishedHandler handlerFinish = null) { if (!isAssetbundleLoaded(strAssetPath)) { if (AssetManager.getInstance().IsStreamingAssets(strAssetPath)) { //异步创建StreamingAssets下资源 strAssetPath = UtilTools.PathCheck(strAssetPath); AssetBundleLoadTask task = new AssetBundleLoadTask(strAssetPath, null); if (handlerFinish != null) { task.EventFinished += handlerFinish; } } else { AssetLoadTask task = new AssetLoadTask(strAssetPath, null); if (handlerFinish != null) { task.EventFinished += handlerFinish; } } } else { if (AssetManager.getInstance().IsStreamingAssets(strAssetPath)) { strAssetPath = UtilTools.PathCheck(strAssetPath); } AssetManager.getInstance().addAssetbundleRefCount(strAssetPath); StartCoroutine("loadAssetAsyncCallback", handlerFinish); } }
IEnumerator loadAssetAsyncCallback(object argsObj) { yield return(new WaitForSeconds(0.1f)); if (argsObj != null) { task.TaskBase.FinishedHandler handlerFinish = (task.TaskBase.FinishedHandler)argsObj; handlerFinish(true, null); } }