コガネブログ

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

【Unity】Odin Inspector で ScriptableObject をリストから作成できるエディタ拡張を実装する

はじめに

 
「Odin Inspector」を使用することで、
ScriptableObject をリストから作成できるエディタ拡張を実装できます

概要

f:id:baba_s:20180327093250p:plain

例えば、Unity プロジェクトにこれらの ScriptableObject のコードが存在して

using UnityEngine;

public class ItemData : ScriptableObject
{
    public int m_id;
    public string m_name;
}

それぞれが、こんな感じで定義されている場合に、

https://bitbucket.org/snippets/Bjarkeck/keRbr4

上記の「ScriptableObjectCreator.cs」を
Unity プロジェクトの「Editor」フォルダに導入して、

f:id:baba_s:20180327093239p:plain

Project ビューを右クリックして「Create Scriptable Object」を選択すると、

f:id:baba_s:20180327093409p:plain

このようなウィンドウが表示されて、
左の一覧から好きな ScriptableObject を選択して、作成できるようになります

参考ツイート

関連記事