使用Unity编辑器类在Inspector面板编辑passWord输入框
在Editor文件夹下创建脚本 InspectorTest
在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.text = EditorGUILayout.PasswordField("Type Somthing", myTest.text);
}
}
Test脚本如下,将其拖拽到需要绘制的对象
using UnityEngine;
using System.Collections;
using UnityEditor;
public class Test : MonoBehaviour {
public string text = "Some text Here";
}