最近使用Unity做项目,接入Addressables插件进行资源加载,当加载 继承 ScriptableObject 创建的 .asset 文件时,总是报错,加载不上。
报错信息如下:
UnityEngine.AddressableAssets.InvalidKeyException: Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown. No Location found for Key=FontConfig/FontConfig
System.Diagnostics.StackTrace:init_frames(Int32, Boolean)
UnityEngine.StackTraceUtility:ExtractStackTrace()
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.AddressableAssets.AddressablesImpl:LogException(AsyncOperationHandle, Exception)
System.Action2:Invoke(T1, T2) UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1:set_OperationException(Exception)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1:Complete(TObject, Boolean, Exception, Boolean) UnityEngine.ResourceManagement.CompletedOperation
1:Execute()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1:InvokeExecute() UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1:Start(ResourceManager, AsyncOperationHandle, DelegateList`1)
UnityEngine.ResourceManagement.ResourceManager:StartOperation(AsyncOperationBa
加载代码如下:
IEnumerator LoadDll()
{
var handler = Addressables.LoadAssetAsync("FontConfig/FontConfig");
yield return handler;
if (handler.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log("load Succeed");
}
}
请问这样加载错在哪里?正确的应该怎样去加载?