关于如何使用Addressables.LoadAssetsAsync的文档很少。
当使用单个字符串作为第一个参数时,它的工作方式与使用Addressables.LoadAssetAsync相同。
所以这是有效的:
Addressables.LoadAssetsAsync<TextAsset>
("questions",OnDownloadQuestionsCategoryComplete)
.Completed += OnDownloadQuestionsComplete;但这会产生一个异常:
Addressables.LoadAssetsAsync<TextAsset>(
new string[] {"questions"},
OnDownloadQuestionsCategoryComplete)
.Completed += OnDownloadQuestionsComplete;生成的异常为:
ChainOperation of Type: System.Collections.Generic.IList`1[UnityEngine.TextAsset]
failed because dependent operation failed
Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=System.String[]发布于 2019-06-29 00:53:52
在LoadAssetsAsync上使用键列表时,需要为MergeMode添加第三个参数。否则,您的列表将被视为IResourceLocation的列表。
private void DownloadQuestions()
{
string[] arrQuestions = new string[]
{
"categories",
"questions_1",
"questions_2",
"questions_3",
"questions_4"
};
Addressables.LoadAssetsAsync<TextAsset>(
arrQuestions,
OnDownloadQuestionsCategoryComplete,
Addressables.MergeMode.Union).Completed += OnDownloadQuestionsComplete;
}
private void OnDownloadQuestionsCategoryComplete(
TextAsset obj) {}
private void OnDownloadQuestionsComplete(
AsyncOperationHandle<IList<TextAsset>> listAssets) {}https://stackoverflow.com/questions/56810522
复制相似问题