The issue is that it doesn’t work at all.
I have, in my MonoBehaviour-derived class, the following fragments of code:
public void Start()
{
ResourceManager.ExceptionHandler = CustomExceptionHandler;
}
// some unrelated code
void CustomExceptionHandler(AsyncOperationHandle handle, Exception exception)
{
if (exception.GetType() != typeof(InvalidKeyException)) {
Addressables.LogException(handle, exception);
} else {
MyLoggingClass.Log((exception as InvalidKeyException).Message);
}
}
I then use a call to Addressables.LoadAssetAsync<GameObject>($"{addressableAssetAddress}"); to load an asset. Specifically, in this call, there’s the potential that “addressableAssetAddress” isn’t the address of a real asset, which will cause it to throw an “UnityEngine.AddressableAssets.InvalidKeyException.” According to the documentation, me setting the ExceptionHandler to my custom handler should cause it to use that exception handler instead of just crashing out normally. However, that’s not what happens (at least in editor). I put breakpoints in the the CustomExceptionHandler, I run, the async method generates the InvalidKeyException, the game crashes, and the CustomExceptionHandler never so much as gets called. Am I doing things wrong, or is this just an issue with the addressables system?