List of sorting layers

I would like to know how to get a list of all sorting layers.

I’m able to access the tags list and layers list by using the class UnityEditorInternal.InternalEditorUtility.
But I can’t find the sorting layers anywhere.

Please advise.

Bump…

Yep, this would definitely be really handy

Agreed. Anyone figure this out?

This property is internal and we can’t get sortingLayers. But…

Type internalEditorUtilityType = typeof(InternalEditorUtility);
PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
string[] sortingLayers = (string[])sortingLayersProperty.GetValue(null, new object[0]);
foreach (string layer in sortingLayers)
{
	Debug.Log(layer);
}
2 Likes