转载:http://blog.csdn.net/liqiangeastsun/article/details/42173403
使用Unity编辑器类在Inspector面板编辑 文本输入框TextField和单选框Toggle
在Editor文件夹下创建脚本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;
}
网友评论