以下の内容はhttps://baba-s.hatenablog.com/entry/2020/03/12/120000より取得しました。


【Unity】Addressable Asset System の ExceptionHandler で例外が出力されたキーと型をログ出力するサンプル

概要

using System;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement;
using UnityEngine.ResourceManagement.AsyncOperations;

internal sealed class Example : MonoBehaviour
{
    private static readonly Regex REGEX = new Regex( "Key=(.*), Type=(.*)" );

    private void Start()
    {
        Addressables.InstantiateAsync( "【存在しないパスを指定】" );
        ResourceManager.ExceptionHandler = Handler;
    }

    private void Handler( AsyncOperationHandle handle, Exception exception )
    {
        var message = exception.Message;

        void Log() => Debug.Log( message );

        if ( !message.Contains( "'UnityEngine.AddressableAssets.InvalidKeyException'" ) )
        {
            Log();
            return;
        }

        var match = REGEX.Match( message );

        if ( !match.Success )
        {
            Log();
            return;
        }

        var groups = match.Groups;
        var key    = groups[ 1 ].Value;
        var type   = groups[ 2 ].Value;

        Debug.Log( $"{key} が見つかりませんでした。({type} 型)" );
    }
}



以上の内容はhttps://baba-s.hatenablog.com/entry/2020/03/12/120000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14