コガネブログ

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

【Unity】リストの並べ替え、ボタンの表示、ScriptableObject のインライン編集などの属性が使用できる「Reorderable Inspector」紹介

はじめに

「Reorderable Inspector」を Unity プロジェクトに導入することで
リストの並べ替え、ボタンの表示、
ScriptableObject のインライン編集などの属性が使用できるようになります

使用例

リストの並べ替え

using SubjectNerd.Utilities;
using UnityEngine;

public class Example : MonoBehaviour
{
    [Reorderable] public string[] list;
}

f:id:baba_s:20180228090517p:plain

ボタンの表示

using UnityEngine;

public class Example : MonoBehaviour
{
    [ContextMenu( "Hoge" )]
    private void Hoge()
    {
        Debug.Log( "ピカチュウ" );
    }
}

f:id:baba_s:20180228091008p:plain

ScriptableObject のインライン編集

using UnityEngine;

public class TestData : ScriptableObject
{
    public int id;
    public string name;
}

...

using SubjectNerd.Utilities;
using UnityEngine;

public class Example : MonoBehaviour
{
    [EditScriptable] public TestData data;
}

f:id:baba_s:20180228091022p:plain