GUILayout.BeginHorizontal();
{
EditorGUILayout.PrefixLabel("Sorting Layer");
// Get the names of the Sorting layers
System.Type internalEditorUtilityType
= typeof(InternalEditorUtility
); PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
string[] names
= (string[])sortingLayersProperty
.GetValue(null,
new object[0]);
int index = 0;
if (!String.IsNullOrEmpty(mPanel.mSortingLayer))
{
for (int i = 0; i < names.Length; i++)
{
if (mPanel.mSortingLayer == names[i])
{
index = i;
break;
}
}
}
// Get the selected index and update the panel sorting layer if it has changed
int selectedIndex = EditorGUILayout.Popup(index, names);
if (index != selectedIndex)
{
mPanel.mSortingLayer = names[selectedIndex];
EditorUtility.SetDirty(mPanel);
}
}
GUILayout.EndHorizontal();