以下の内容はhttps://baba-s.hatenablog.com/entry/2017/12/29/095000より取得しました。


【Unity】Inspector 内に他オブジェクトの Custom Inspector を表示する「Editor.CreateEditor」

概要

using UnityEngine;

public class Example : MonoBehaviour
{
    public RectTransform target;
}
using UnityEditor;

[CustomEditor( typeof( Example ) )]
public class ExampleEditor : Editor
{
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        var target = serializedObject.FindProperty( "target" );
        if ( target == null ) return;
        var editor = CreateEditor( target.objectReferenceValue );
        if ( editor == null ) return;
        editor.OnInspectorGUI();
    }
}

このようなエディタ拡張のスクリプトを作成した場合

f:id:baba_s:20171229094507p:plain

Example コンポーネントの Inspector に
RectTransform の Custom Inspector が表示されます

関連記事




以上の内容はhttps://baba-s.hatenablog.com/entry/2017/12/29/095000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14