コガネブログ

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

【Unity】2つの PropertyAttribute が使用できる「Essential Editor」紹介

はじめに

「Essential Editor」を Unity プロジェクトに導入することで
2つの PropertyAttribute が使用できるようになります

使用例

f:id:baba_s:20180104150824p:plain

使い方

using EssentialEditor;
using UnityEngine;

public class Example : MonoBehaviour
{
    [ExposeMethod]
    private void Foo()
    {
    }

    [ExposeMethod]
    private int Goo()
    {
        return 1;
    }

    [ExposeMethod]
    private string Hoo( int x, float y, Vector3 z, string w )
    {
        return w;
    }
}

f:id:baba_s:20180104151143p:plain

ExposeMethod 属性を使用すると、
Inspector に関数を実行するためのボタンが表示されます

using EssentialEditor;
using UnityEngine;

public class Example : MonoBehaviour
{
    private float foo;

    [ExposeProperty]
    public float Foo
    {
        get { return foo; }
        set { foo = value; }
    }

    [ExposeProperty]
    public float Goo
    {
        get { return foo; }
    }

    [ExposeProperty]
    public Vector3 Hoo
    {
        get;
        set;
    }
}

f:id:baba_s:20180104151302p:plain

ExposeProperty 属性を使用すると
Inspector でプロパティを編集できるようになります

関連記事