枚举器
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System;
using System.Reflection;
[CustomEditor(typeof(GameObjLayerlogic))]
public class GameObjLayerlogicInspector : Editor {
public override void OnInspectorGUI()
{
GameObjLayerlogic myLogic=target as GameObjLayerlogic;
Type t = typeof(InternalEditorUtility);
PropertyInfo prop = t.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
string[] x=(string[])prop.GetValue(null, null);
//myLogic.LayerName=
int current = 0;
if (myLogic.LayerName != null) current = Array.IndexOf(x, myLogic.LayerName);
if (current <= -1 ) current = 0;
int newSortingLayerIndex = EditorGUILayout.Popup("Sorting Layer", current, x);
myLogic.LayerName=x[newSortingLayerIndex];
myLogic.sortingOrder = EditorGUILayout.IntField("Number of clones:", myLogic.sortingOrder);
}
}