private IEnumerator WaitToLoadAsset() { string bundleName = inputLoadBundleName.text; string name = inputLoadAssetName.text; AssetBundleLoadAssetOperation operation = AssetBundleLoader.LoadAssetAsync <Object>(bundleName, name); yield return(operation); if (!operation.isError && operation.isDone) { Object org = operation.GetAsset <Object>(); Instantiate(org); Debug.LogFormat("'{0}' 的 '{0}' 创建成功", operation.assetBundleName, operation.assetName); } }
/// <summary> /// 异步加载Asset /// </summary> /// <typeparam name="T"></typeparam> /// <param name="assetBundleName"></param> /// <param name="assetName"></param> /// <returns></returns> public static AssetBundleLoadAssetOperation LoadAssetAsync <T>(string assetBundleName, string assetName) where T : UnityEngine.Object { if (!CheckInitialize()) { return(null); } //创建一个读取作业 AssetBundleLoadAssetOperation opertaion = new AssetBundleLoadAssetOperation(assetBundleName, assetName, typeof(T)); m_InProgressLoadOpertaions.Add(opertaion); //下载相应的assetbundle DownLoadAssetBundle(assetBundleName); return(opertaion); }