ソースコード
上記のスクリプトを Unity プロジェクトの「Editor」フォルダに追加します
使い方
MonoBehaviour を継承したクラスのスクリプトを右クリックして
「Create>Custom Inspector」を選択します
すると、Editor フォルダに Custom Inspector のスクリプトが追加されます
using UnityEngine; using UnityEditor; using System.Collections; using System.Collections.Generic; [CustomEditor(typeof(NewBehaviourScript))] //[CanEditMultipleObjects] public class NewBehaviourScriptInspector : Editor { void OnEnable() { // TODO: find properties we want to work with //serializedObject.FindProperty(); } public override void OnInspectorGUI() { // Update the serializedProperty - always do this in the beginning of OnInspectorGUI. serializedObject.Update(); // TODO: Draw UI here //EditorGUILayout.PropertyField(); DrawDefaultInspector(); // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI. serializedObject.ApplyModifiedProperties(); } }
コードの内容はこのようになっています
参考ツイート
Hey friends have this lil editor extension that automagically generates a custom inspector class for you! #unitytips https://t.co/oGiZSqtVeo pic.twitter.com/vrlToFLNPB
— Lotte 💖💝🍓🌈🐹 WINTER ver. ❄️⛄️ (@LotteMakesStuff) 2017年1月15日