docs.unity.cn
    Show / Hide Table of Contents

    ResourceManager.ExceptionHandler

    API

    • static Action<AsyncOperationHandle, Exception> ExceptionHandler

    Description

    The ResourceManager.ExceptionHandler allows you to create and set custom exception handlers for the Addressables runtime. If no ExceptionHandler is provided, a default implementation is used.

    Exceptions created during runtime error scenarios do not get automatically thrown. They are sent to the ExceptionHandler and reported in the AsyncOperationHandle.OperationException of any given operation.

    Code Sample

    void Start()
    {
        ResourceManager.ExceptionHandler = CustomExceptionHandler;
    
        //...
    }
    
    //Gets called for every error scenario encountered during an operation.
    //A common use case for this is having InvalidKeyExceptions fail silently when a location is missing for a given key.
    void CustomExceptionHandler(AsyncOperationHandle handle, Exception exception)
    {
        if (exception.GetType() != typeof(InvalidKeyException))
                Addressables.LogException(handle, exception);
    }
    
    Back to top Copyright © 2021 Unity Technologies
    Generated by DocFX
    on 04 November 2021
    Terms of use