轉(zhuǎn)載:http://blog.csdn.net/liqiangeastsun/article/details/42173403
使用Unity編輯器類在Inspector面板編輯 文本輸入框TextField和單選框Toggle
在Editor文件夾下創(chuàng)建腳本InspectorTest
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(Test))]
public class InspectorTest : Editor {
public override void OnInspectorGUI()
{
Test myTest = (Test)target;
myTest.MyName = EditorGUILayout.TextField("Object Name", myTest.MyName);
myTest.showBtn = EditorGUILayout.Toggle("Show Button ", myTest.showBtn);
}
}
Test腳本如下,將其拖拽到需要繪制的腳本即可
using UnityEngine;
using System.Collections;
using UnityEditor;
public class Test : MonoBehaviour {
public string MyName;
public bool showBtn = true;
}