使用Unity编辑器类在 Inspector面板编辑 Vector2、Vector3、Vector4
在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.pp2 = EditorGUILayout.Vector2Field("Point 2 ", myTest.pp2);
myTest.pp3 = EditorGUILayout.Vector3Field("Point 3 ", myTest.pp3);
myTest.pp4 = EditorGUILayout.Vector4Field("Point 4 ", myTest.pp4);
}
}
Test脚本如下,将其拖拽到需要绘制的脚本即可
using UnityEngine;
using System.Collections;
using UnityEditor;
public class Test : MonoBehaviour {
public Vector2 pp2;
public Vector3 pp3;
public Vector4 pp4;
}