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


【Unity】タグ付きのデバッグログなどを使用できるパッケージ「UniDebugLogger」を GitHub に公開しました

リポジトリ

使用例

using UniDebugLogger;
using UnityEngine;

public class Example : MonoBehaviour
{
    private void Awake()
    {
        IDebugLogger logger;

        logger = DefaultDebugLogger.Instance;

        logger.Log( "Log" );
        logger.Log( "Log", gameObject );
        logger.LogWarning( "LogWarning" );
        logger.LogWarning( "LogWarning", gameObject );
        logger.LogError( "LogError" );
        logger.LogError( "LogError", gameObject );
        logger.LogFormat( "LogFormat {0} / {1}", 1, 2 );
        logger.LogFormat( gameObject, "LogFormat {0} / {1}", 1, 2 );
        logger.LogWarningFormat( "LogWarningFormat {0} / {1}", 1, 2 );
        logger.LogWarningFormat( gameObject, "LogWarningFormat {0} / {1}", 1, 2 );
        logger.LogErrorFormat( "LogErrorFormat {0} / {1}", 1, 2 );
        logger.LogErrorFormat( gameObject, "LogErrorFormat {0} / {1}", 1, 2 );

        logger = TaggedDebugLogger.Create( "タイトル" );

        logger.Log( "Log" );
        logger.Log( "Log", gameObject );
        logger.LogWarning( "LogWarning" );
        logger.LogWarning( "LogWarning", gameObject );
        logger.LogError( "LogError" );
        logger.LogError( "LogError", gameObject );
        logger.LogFormat( "LogFormat {0} / {1}", 1, 2 );
        logger.LogFormat( gameObject, "LogFormat {0} / {1}", 1, 2 );
        logger.LogWarningFormat( "LogWarningFormat {0} / {1}", 1, 2 );
        logger.LogWarningFormat( gameObject, "LogWarningFormat {0} / {1}", 1, 2 );
        logger.LogErrorFormat( "LogErrorFormat {0} / {1}", 1, 2 );
        logger.LogErrorFormat( gameObject, "LogErrorFormat {0} / {1}", 1, 2 );

        logger = NullDebugLogger.Instance;

        logger.Log( "Log" );
        logger.Log( "Log", gameObject );
        logger.LogWarning( "LogWarning" );
        logger.LogWarning( "LogWarning", gameObject );
        logger.LogError( "LogError" );
        logger.LogError( "LogError", gameObject );
        logger.LogFormat( "LogFormat {0} / {1}", 1, 2 );
        logger.LogFormat( gameObject, "LogFormat {0} / {1}", 1, 2 );
        logger.LogWarningFormat( "LogWarningFormat {0} / {1}", 1, 2 );
        logger.LogWarningFormat( gameObject, "LogWarningFormat {0} / {1}", 1, 2 );
        logger.LogErrorFormat( "LogErrorFormat {0} / {1}", 1, 2 );
        logger.LogErrorFormat( gameObject, "LogErrorFormat {0} / {1}", 1, 2 );
    }
}

補足

  • DISABLE_UNI_DEBUG_LOGGER シンボルを定義することですべてのデバッグログを無効化できる



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

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