Ejemplo n.º 1
0
    public void OnInspectorGUI()
    {
        EditorGUILayout.BeginHorizontal();
        {
            filterName = EditorGUILayout.TextField("Filter name: ", filterName);

            EditorConfig.SetColor(EditorConfig.AddButtonColor);
            if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth))
            {
                // Filters within a style are identified by their filter name
                var queryFilterStyleName = style.FilterStyles.Where(filterStyle => filterStyle.Name == filterName);

                if (filterName.Length == 0)
                {
                    Debug.LogError("The filter name can't be empty");
                }
                else if (queryFilterStyleName.Count() > 0)
                {
                    Debug.LogError("Filter with name " + filterName + " already exists");
                }
                else
                {
                    var filterStyle = new FeatureStyle.FilterStyle(filterName);
                    style.AddFilterStyle(filterStyle);
                    filterStyleEditors.Add(new FilterStyleEditor(filterStyle));
                }
            }
            EditorConfig.ResetColor();
        }
        EditorGUILayout.EndHorizontal();

        EditorGUI.indentLevel++;

        for (int i = filterStyleEditors.Count - 1; i >= 0; i--)
        {
            var editor      = filterStyleEditors[i];
            var filterStyle = editor.FilterStyle;

            var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), filterStyle.Name);

            if (state.show)
            {
                editor.OnInspectorGUI();
            }

            if (state.markedForDeletion)
            {
                style.RemoveFilterStyle(filterStyle);

                // Remove the editor for this filter
                filterStyleEditors.RemoveAt(i);
            }
        }

        EditorGUI.indentLevel--;
    }
Ejemplo n.º 2
0
    public void OnInspectorGUI()
    {
        // Default layers
        EditorGUILayout.BeginHorizontal();
        {
            selectedLayer = EditorGUILayout.Popup("Default layer:", selectedLayer, defaultLayers.ToArray());
            AddLayerStyleLayout(filterStyle, defaultLayers[selectedLayer]);
        }
        EditorGUILayout.EndHorizontal();

        // Custom layer entry
        EditorGUILayout.BeginHorizontal();
        {
            customFeatureCollection = EditorGUILayout.TextField("Custom layer:", customFeatureCollection);
            AddLayerStyleLayout(filterStyle, customFeatureCollection);
        }
        EditorGUILayout.EndHorizontal();

        EditorGUI.indentLevel++;

        for (int i = layerStyleEditors.Count - 1; i >= 0; i--)
        {
            var editor       = layerStyleEditors[i];
            var layerStyling = editor.LayerStyle;

            var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), layerStyling.LayerName);

            if (state.show)
            {
                editor.OnInspectorGUI();
            }

            if (state.markedForDeletion)
            {
                // Remove the layer from the filter styles
                filterStyle.RemoveLayerStyle(layerStyling);

                // Remove the associated layer editor
                layerStyleEditors.RemoveAt(i);
            }
        }

        EditorGUI.indentLevel--;

        // TODO: Matchers
    }