Unity之EditorGUILayout-TextField、

作者: 循环渐进123456 | 来源:发表于2017-09-11 08:58 被阅读10次

转载: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;  
  
}  

相关文章

网友评论

    本文标题:Unity之EditorGUILayout-TextField、

    本文链接:https://www.haomeiwen.com/subject/dyyxsxtx.html