在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.xx = EditorGUILayout.IntSlider(myTest.xx, 1, 10);
myTest.yy = EditorGUILayout.IntSlider(myTest.yy, 2, 8);
myTest.zz = EditorGUILayout.IntSlider(myTest.zz , 0, 100);
}
}
Test脚本如下,将其拖拽到需要绘制的脚本上即可
using UnityEngine;
using System.Collections;
using UnityEditor;
public class Test : MonoBehaviour {
public int xx = 3;
public int yy = 5;
public int zz = 80;
}