コガネブログ

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

【Unity】Inspector のパラメータの欄に GetComponent ボタンを追加する Attribute

ソースコード

使い方

using UnityEngine;

public class Example : MonoBehaviour
{
    [GetComponent] public Transform transform;
    [GetComponent] public Example example;
}

f:id:baba_s:20180118130336p:plain

スポイトボタンを押すと、
ゲームオブジェクトから対象のコンポーネントを GetComponent します