Getting a list of sorting layers and the ids without using UnityEditorInternal

I am building a system that needs to maintain an association between the Unity sorting layers and my own internal layers. To do this I need to get a list of Unity layers and their ids at runtime. I have been using this code which has worked great

string[] GetSortingLayerNames()
{
    System.Type internalEditorUtilityType = typeof(InternalEditorUtility);
    PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);

    return (string[])sortingLayersProperty.GetValue(null, new object[0]);
}

int[] GetSortingLayerUniqueIDs(bool sortNum = false)
{
    System.Type internalEditorUtilityType = typeof(InternalEditorUtility);
    PropertyInfo sortingLayerUniqueIDsProperty = internalEditorUtilityType.GetProperty("sortingLayerUniqueIDs", BindingFlags.Static | BindingFlags.NonPublic);

    int[] idArray = (int[])sortingLayerUniqueIDsProperty.GetValue(null, new object[0]);

    if (sortNum)
    {
        Array.Sort(idArray);
    }

    return idArray;
}

The problem is it uses the namespace UnityEditorInternal which to my understanding does not exist once you build your project. Is there a way I can get my hands on this information without using editor namespaces? It seems like a pretty silly oversight to not give devs access to this useful information…

Thanks

To solve this I was forced to just save the layer information in the editor for use in game. It is not ideal but it works.