コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】簡単にパラメータのデバッグ表示ができる「Debug Viewer」紹介

はじめに

「Debug Viewer」を Unity プロジェクトに導入することで
簡単にパラメータのデバッグ表示ができるようになります

使用例

using DebugViewer;
using UnityEngine;

public class PlayerHealth : MonoBehaviour
{
    [Debug( "Player", "Max Health" )]     public int maxHealth     = 100;
    [Debug( "Player", "Current Health" )] public int currentHealth = 100;

    public int walkSpeed = 5;
    public int runSpeed  = 10;

    public int meleeDamage = 9;
    public int shootDamage = 6;

    private void Awake()
    {
        DebugViewer.DebugViewer.AddInformationToCatergory( "Movement", new DebugInformation( "Walk Speed", this, "walkSpeed" ), true );
        DebugViewer.DebugViewer.AddInformationToCatergory( "Movement", new DebugInformation( "Run Speed", this, "runSpeed" ), true );

        DebugViewer.DebugViewer.AddInformationToCatergory( "Damage", new DebugInformation( "Melee Damage", this, "meleeDamage" ), true );
        DebugViewer.DebugViewer.AddInformationToCatergory( "Damage", new DebugInformation( "Shoot Damage", this, "shootDamage" ), true );
    }
}

f:id:baba_s:20210920220117p:plain