转载:http://blog.csdn.net/liqiangeastsun/article/details/42173291
使用编辑器类在Inspecotr面板编辑 Layer、Mask、Tag
1
2
3
4
在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.selectLayer = EditorGUILayout.LayerField("Layer Objects", myTest.selectLayer);
myTest.selectFlag = EditorGUILayout.MaskField("player Flags ", myTest.selectFlag, myTest.options);
myTest.tagStr = EditorGUILayout.TagField("Tag for Objects:", myTest.tagStr);
}
}
Test脚本如下,将其拖拽到需要绘制的对象上即可
using UnityEngine;
using System.Collections;
using UnityEditor;
public class Test : MonoBehaviour {
public int selectLayer = 0;
public int selectFlag = 0;
public string[] options = { "CanJump", "CanShoot", "CanSwim"};
public string tagStr = "";
}