コガネブログ

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

【Unity】const や static readonly を Inspector のドロップダウンで選択できる「Drop-down with objects of any type in Unity Inspector」紹介

はじめに

「Drop-down with objects of any type in Unity Inspector」を
Unity プロジェクトに導入することで
const や static readonly を Inspector のドロップダウンで選択できるようになります

使用例

using StructDropDown;
using UnityEngine;

public static class Const
{
    public const int MAX = 100;
    public const int MIN = 0;
}

public static class StaticReadOnly
{
    public static readonly Vector2 Zero = Vector2.zero;
    public static readonly Vector2 One  = Vector2.one;
}

public class Example : MonoBehaviour
{
    [DropDown( typeof( Const ) )]
    public int m_value;

    [DropDown( typeof( StaticReadOnly ) )]
    public Vector2 m_vector;
}