예제 #1
0
    int DrawLayerPopup(Rect position, GUIContent label, int currentLayer)
    {
        int[]    layers       = LayerHelper.GetAllLayers();
        string[] layerNames   = new string[layers.Length];
        int      currentIndex = 0;

        // Fill names array
        for (int i = 0; i < layers.Length; i++)
        {
            layerNames[i] = LayerMask.LayerToName(layers[i]);

            if (layers[i] == currentLayer)
            {
                currentIndex = i;
            }
        }

        // Draw
        int index = EditorGUI.Popup(position, label.text, currentIndex, layerNames);

        // Get layer from name via index
        return(LayerMask.NameToLayer(layerNames[index]));
    }