public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            ColliderOptions colliderOptions = (ColliderOptions)EditorHelper.GetTargetObjectOfProperty(property);

            EditorGUI.BeginProperty(position, null, property);
            var colliderTypeLabel = new GUIContent
            {
                text    = "Collider Type",
                tooltip = "The type of collider added to game objects in this layer."
            };
            var colliderTypeProperty = property.FindPropertyRelative("colliderType");

            var displayNames = colliderTypeProperty.enumDisplayNames;
            int count        = colliderTypeProperty.enumDisplayNames.Length;

            if (!isGUIContentSet)
            {
                colliderTypeContent = new GUIContent[count];
                for (int extIdx = 0; extIdx < count; extIdx++)
                {
                    colliderTypeContent[extIdx] = new GUIContent
                    {
                        text    = displayNames[extIdx],
                        tooltip = EnumExtensions.Description((ColliderType)extIdx),
                    };
                }
                isGUIContentSet = true;
            }

            colliderTypeProperty.enumValueIndex = EditorGUILayout.Popup(colliderTypeLabel, colliderTypeProperty.enumValueIndex, colliderTypeContent);
            EditorHelper.CheckForModifiedProperty(colliderTypeProperty, colliderOptions);

            EditorGUI.EndProperty();
        }
Ejemplo n.º 2
0
        public void DrawUI(SerializedProperty layerProperty, VectorPrimitiveType primitiveTypeProp, VectorSourceType sourceType)
        {
            showGameplay = EditorGUILayout.Foldout(showGameplay, "Behavior Modifiers");
            if (showGameplay)
            {
                bool isPrimitiveTypeValidForBuidingIds = (primitiveTypeProp == VectorPrimitiveType.Polygon || primitiveTypeProp == VectorPrimitiveType.Custom);
                bool isSourceValidForBuildingIds       = sourceType != VectorSourceType.MapboxStreets;

                layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = isPrimitiveTypeValidForBuidingIds && isSourceValidForBuildingIds;

                if (layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue == true)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("buildingsWithUniqueIds"), new GUIContent
                    {
                        text    = "Buildings With Unique Ids",
                        tooltip =
                            "Turn on this setting only when rendering 3D buildings from the Mapbox Streets with Building Ids tileset. Using this setting with any other polygon layers or source will result in visual artifacts. "
                    });
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(layerProperty);
                    }
                }

                var subLayerCoreOptions   = layerProperty.FindPropertyRelative("coreOptions");
                var combineMeshesProperty = subLayerCoreOptions.FindPropertyRelative("combineMeshes");

                EditorGUILayout.BeginHorizontal();
                if (combineMeshesProperty.boolValue == false)
                {
                    var        featurePositionProperty = layerProperty.FindPropertyRelative("moveFeaturePositionTo");
                    GUIContent dropDownLabel           = new GUIContent
                    {
                        text    = "Feature Position",
                        tooltip = "Position to place feature in the tile. "
                    };

                    GUIContent[] dropDownItems = new GUIContent[featurePositionProperty.enumDisplayNames.Length];

                    for (int i = 0; i < featurePositionProperty.enumDisplayNames.Length; i++)
                    {
                        dropDownItems[i] = new GUIContent
                        {
                            text = featurePositionProperty.enumDisplayNames[i]
                        };
                    }
                    EditorGUI.BeginChangeCheck();
                    featurePositionProperty.enumValueIndex = EditorGUILayout.Popup(dropDownLabel, featurePositionProperty.enumValueIndex, dropDownItems);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(layerProperty);
                    }
                }
                EditorGUILayout.EndHorizontal();
                DrawMeshModifiers(layerProperty);
                DrawGoModifiers(layerProperty);
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(property.FindPropertyRelative("Width"));

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }
        }
        private void ShowCategoryOptions(SerializedProperty property)
        {
            //Category drop down
            EditorGUI.BeginChangeCheck();
            var categoryProp = property.FindPropertyRelative("categories");

            categoryProp.intValue = (int)(LocationPrefabCategories)(EditorGUILayout.EnumFlagsField(categoriesDropDown, (LocationPrefabCategories)categoryProp.intValue));
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }
            ShowDensitySlider(property);
        }
        void CellGUI(Rect cellRect, TreeViewItem <FeatureTreeElement> item, FeatureSubLayerColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            if (Layers == null || Layers.arraySize == 0)
            {
                return;
            }

            if (Layers.arraySize <= args.item.id - uniqueId)
            {
                return;
            }

            var layer = Layers.GetArrayElementAtIndex(args.item.id - uniqueId);

            CenterRectUsingSingleLineHeight(ref cellRect);
            if (column == FeatureSubLayerColumns.Name)
            {
                Rect toggleRect = cellRect;
                toggleRect.x    += GetContentIndent(item);
                toggleRect.width = kToggleWidth;

                EditorGUI.BeginChangeCheck();
                item.data.isActive = layer.FindPropertyRelative("coreOptions.isActive").boolValue;
                if (toggleRect.xMax < cellRect.xMax)
                {
                    item.data.isActive = EditorGUI.Toggle(toggleRect, item.data.isActive);                     // hide when outside cell rect
                }
                layer.FindPropertyRelative("coreOptions.isActive").boolValue = item.data.isActive;
                if (EditorGUI.EndChangeCheck())
                {
                    VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(layer);
                    EditorHelper.CheckForModifiedProperty(layer, vectorSubLayerProperties.coreOptions);
                }

                cellRect.xMin += nameOffset;                 // Adding some gap between the checkbox and the name
                args.rowRect   = cellRect;

                layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = item.data.Name;
                //This draws the name property
                base.RowGUI(args);
            }
            if (column == FeatureSubLayerColumns.Type)
            {
                cellRect.xMin += 15f;                 // Adding some gap between the checkbox and the name

                var typeString = ((PresetFeatureType)layer.FindPropertyRelative("presetFeatureType").intValue).ToString();
                item.data.Type = typeString;
                EditorGUI.LabelField(cellRect, item.data.Type, columnStyle);
            }
        }
        private void ShowPOINames(SerializedProperty property)
        {
            //Name field
            var categoryProp = property.FindPropertyRelative("nameString");

            EditorGUI.BeginChangeCheck();
            categoryProp.stringValue = EditorGUILayout.TextField(nameField, categoryProp.stringValue);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            ShowDensitySlider(property);
        }
        private void ShowDensitySlider(SerializedProperty property)
        {
            //Density slider
            var densityProp = property.FindPropertyRelative("density");

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(densityProp, densitySlider);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }
            GUI.enabled = true;
            densityProp.serializedObject.ApplyModifiedProperties();
        }
        private void ShowAddressOrLatLonUI(SerializedProperty property)
        {
            //EditorGUILayout.BeginVertical();
            var coordinateProperties = property.FindPropertyRelative("coordinates");

            for (int i = 0; i < coordinateProperties.arraySize; i++)
            {
                EditorGUILayout.BeginHorizontal();
                //get the element to draw
                var coordinate = coordinateProperties.GetArrayElementAtIndex(i);

                //label for each location.
                var coordinateLabel = String.Format("Location {0}", i);

                // draw coordinate string.
                EditorGUI.BeginChangeCheck();
                coordinate.stringValue = EditorGUILayout.TextField(coordinateLabel, coordinate.stringValue);

                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(property, true);
                }
                // draw search button.
                if (GUILayout.Button(new GUIContent(searchButtonContent), (GUIStyle)"minibuttonleft", GUILayout.MaxWidth(100)))
                {
                    object propertyObject = EditorHelper.GetTargetObjectOfProperty(property);
                    GeocodeAttributeSearchWindow.Open(coordinate, propertyObject);
                }

                //include a remove button in the row
                if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.MaxWidth(30)))
                {
                    coordinateProperties.DeleteArrayElementAtIndex(i);
                    EditorHelper.CheckForModifiedProperty(property);
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(EditorGUIUtility.labelWidth - 3);

            if (GUILayout.Button(new GUIContent("Add Location"), (GUIStyle)"minibutton"))
            {
                coordinateProperties.arraySize++;
                var newElement = coordinateProperties.GetArrayElementAtIndex(coordinateProperties.arraySize - 1);
                newElement.stringValue = "";
                EditorHelper.CheckForModifiedProperty(property);
            }
            EditorGUILayout.EndHorizontal();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, null, property);

            var primitiveType = property.FindPropertyRelative("geometryType");

            var primitiveTypeLabel = new GUIContent
            {
                text    = "Primitive Type",
                tooltip = "Primitive geometry type of the visualizer, allowed primitives - point, line, polygon."
            };

            var displayNames = primitiveType.enumDisplayNames;
            int count        = primitiveType.enumDisplayNames.Length;

            if (!_isGUIContentSet)
            {
                _primitiveTypeContent = new GUIContent[count];
                for (int extIdx = 0; extIdx < count; extIdx++)
                {
                    _primitiveTypeContent[extIdx] = new GUIContent
                    {
                        text    = displayNames[extIdx],
                        tooltip = EnumExtensions.Description((VectorPrimitiveType)extIdx),
                    };
                }
                _isGUIContentSet = true;
            }

            EditorGUI.BeginChangeCheck();
            primitiveType.enumValueIndex = EditorGUILayout.Popup(primitiveTypeLabel, primitiveType.enumValueIndex, _primitiveTypeContent);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }
//
//			if ((VectorPrimitiveType)primitiveType.enumValueIndex == VectorPrimitiveType.Line)
//			{
//				EditorGUI.BeginChangeCheck();
//				EditorGUILayout.PropertyField(property.FindPropertyRelative("lineWidth"));
//				if (EditorGUI.EndChangeCheck())
//				{
//					EditorHelper.CheckForModifiedProperty(property);
//				}
//			}
            EditorGUI.EndProperty();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.indentLevel++;
            GUILayout.Space(-1f * _lineHeight);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(property.FindPropertyRelative("latitudeLongitude"));
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(property.FindPropertyRelative("zoom"), GUILayout.Height(_lineHeight));
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }
            EditorGUI.indentLevel--;
        }
Ejemplo n.º 11
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
            VectorFilterOptions options = (VectorFilterOptions)EditorHelper.GetTargetObjectOfProperty(property);

            showFilters = EditorGUILayout.Foldout(showFilters, new GUIContent {
                text = "Filters", tooltip = "Filter features in a vector layer based on criterion specified.  "
            });
            if (showFilters)
            {
                var propertyFilters = property.FindPropertyRelative("filters");

                for (int i = 0; i < propertyFilters.arraySize; i++)
                {
                    DrawLayerFilter(property, propertyFilters, i, options);
                }
                if (propertyFilters.arraySize > 0)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(property.FindPropertyRelative("combinerType"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }
                }
                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 12);

                EditorGUI.BeginChangeCheck();
                if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibutton"))
                {
                    options.AddFilter();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(property);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(property.FindPropertyRelative("Width"));
            property.FindPropertyRelative("JoinType").enumValueIndex = (int)((LineJoinType)EditorGUILayout.EnumPopup("Join Type", (LineJoinType)property.FindPropertyRelative("JoinType").intValue));
            if (property.FindPropertyRelative("JoinType").enumValueIndex == (int)LineJoinType.Miter || property.FindPropertyRelative("JoinType").enumValueIndex == (int)LineJoinType.Bevel)
            {
                EditorGUILayout.PropertyField(property.FindPropertyRelative("MiterLimit"));
            }
            else if (property.FindPropertyRelative("JoinType").enumValueIndex == (int)LineJoinType.Round)
            {
                EditorGUILayout.PropertyField(property.FindPropertyRelative("RoundLimit"));
            }

            property.FindPropertyRelative("CapType").enumValueIndex = (int)((LineCapType)EditorGUILayout.EnumPopup("Cap Type", (LineCapType)property.FindPropertyRelative("CapType").intValue));

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }
        }
        public void DrawUI(SerializedProperty subLayerCoreOptions, SerializedProperty layerProperty, VectorPrimitiveType primitiveTypeProp)
        {
            VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(layerProperty);

            objectId = layerProperty.serializedObject.targetObject.GetInstanceID().ToString();

            EditorGUILayout.BeginVertical();
            showModeling = EditorGUILayout.Foldout(showModeling, new GUIContent {
                text = "Modeling", tooltip = "This section provides you with options to fine tune your meshes"
            });
            if (showModeling)
            {
                GUILayout.Space(-_lineHeight);
                EditorGUILayout.PropertyField(subLayerCoreOptions);

                if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
                {
                    GUILayout.Space(-_lineHeight);
                    var extrusionOptions = layerProperty.FindPropertyRelative("extrusionOptions");
                    extrusionOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
                    EditorGUILayout.PropertyField(extrusionOptions);
                }

                var snapToTerrainProperty = subLayerCoreOptions.FindPropertyRelative("snapToTerrain");
                snapToTerrainProperty.boolValue = EditorGUILayout.Toggle(snapToTerrainProperty.displayName, snapToTerrainProperty.boolValue);
                EditorHelper.CheckForModifiedProperty(snapToTerrainProperty, vectorSubLayerProperties);

                var combineMeshesProperty = subLayerCoreOptions.FindPropertyRelative("combineMeshes");
                combineMeshesProperty.boolValue = EditorGUILayout.Toggle(combineMeshesProperty.displayName, combineMeshesProperty.boolValue);
                EditorHelper.CheckForModifiedProperty(combineMeshesProperty, vectorSubLayerProperties);

                if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
                {
                    EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("colliderOptions"));
                }
            }
            EditorGUILayout.EndVertical();
        }
        void OnGUI()
        {
            GUILayout.Label("Search for a location");

            string oldSearchInput = _searchInput;

            GUI.SetNextControlName(searchFieldName);
            _searchInput = GUILayout.TextField(_searchInput);

            if (_searchInput.Length == 0)
            {
                GUILayout.Label("Type in a location to find it's latitude and longtitude");
            }
            else
            {
                bool changed = oldSearchInput != _searchInput;
                if (changed)
                {
                    HandleUserInput(_searchInput);
                }

                if (_features.Count > 0)
                {
                    GUILayout.Label("Results:");
                    for (int i = 0; i < _features.Count; i++)
                    {
                        Feature feature     = _features[i];
                        string  coordinates = feature.Center.x.ToString(CultureInfo.InvariantCulture) + ", " +
                                              feature.Center.y.ToString(CultureInfo.InvariantCulture);

                        //abreviated coords for display in the UI
                        string truncatedCoordinates = feature.Center.x.ToString("F2", CultureInfo.InvariantCulture) + ", " +
                                                      feature.Center.y.ToString("F2", CultureInfo.InvariantCulture);

                        //split feature name and add elements until the maxButtonContentLenght is exceeded
                        string[] featureNameSplit       = feature.PlaceName.Split(',');
                        string   buttonContent          = "";
                        int      maxButtonContentLength = 30;
                        for (int j = 0; j < featureNameSplit.Length; j++)
                        {
                            if (buttonContent.Length + featureNameSplit[j].Length < maxButtonContentLength)
                            {
                                if (String.IsNullOrEmpty(buttonContent))
                                {
                                    buttonContent = featureNameSplit[j];
                                }
                                else
                                {
                                    buttonContent = buttonContent + "," + featureNameSplit[j];
                                }
                            }
                        }

                        if (buttonContent.Length < maxButtonContentLength + 15)
                        {
                            buttonContent = buttonContent + "," + " (" + truncatedCoordinates + ")";
                        }


                        if (GUILayout.Button(buttonContent))
                        {
                            _coordinateProperty.stringValue = coordinates;
                            _coordinateProperty.serializedObject.ApplyModifiedProperties();
                            EditorUtility.SetDirty(_coordinateProperty.serializedObject.targetObject);

                            if (_objectToUpdate != null)
                            {
                                EditorHelper.CheckForModifiedProperty(_coordinateProperty, _objectToUpdate, true);
                            }
                            Close();
                        }
                    }
                }
                else
                {
                    if (_isSearching)
                    {
                        GUILayout.Label("Searching...");
                    }
                    else
                    {
                        GUILayout.Label("No search results");
                    }
                }
            }

            if (!hasSetFocus)
            {
                GUI.FocusControl(searchFieldName);
                hasSetFocus = true;
            }
        }
Ejemplo n.º 15
0
        private void DrawLayerFilter(SerializedProperty originalProperty, SerializedProperty propertyFilters, int index, VectorFilterOptions vectorFilterOptions)
        {
            var property = propertyFilters.GetArrayElementAtIndex(index);

            var filterOperatorProp = property.FindPropertyRelative("filterOperator");

            EditorGUILayout.BeginVertical();

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(new GUIContent {
                text = "Key", tooltip = "Name of the property to use as key. This property is case sensitive."
            }, GUILayout.MaxWidth(150));

            switch ((LayerFilterOperationType)filterOperatorProp.enumValueIndex)
            {
            case LayerFilterOperationType.IsEqual:
            case LayerFilterOperationType.IsGreater:
            case LayerFilterOperationType.IsLess:
                EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
                EditorGUILayout.LabelField(numValueGui, GUILayout.MaxWidth(100));
                break;

            case LayerFilterOperationType.Contains:
                EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
                EditorGUILayout.LabelField(strValueGui, GUILayout.MaxWidth(100));
                break;

            case LayerFilterOperationType.IsInRange:
                EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
                EditorGUILayout.LabelField(minValueGui, GUILayout.MaxWidth(100));
                EditorGUILayout.LabelField(maxValueGui, GUILayout.MaxWidth(100));
                break;

            default:
                break;
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            var selectedLayerName = originalProperty.FindPropertyRelative("_selectedLayerName").stringValue;

            DrawPropertyDropDown(originalProperty, property);

            EditorGUI.BeginChangeCheck();
            filterOperatorProp.enumValueIndex = EditorGUILayout.Popup(filterOperatorProp.enumValueIndex, filterOperatorProp.enumDisplayNames, GUILayout.MaxWidth(150));
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            EditorGUI.BeginChangeCheck();
            switch ((LayerFilterOperationType)filterOperatorProp.enumValueIndex)
            {
            case LayerFilterOperationType.IsEqual:
            case LayerFilterOperationType.IsGreater:
            case LayerFilterOperationType.IsLess:
                property.FindPropertyRelative("Min").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Min").doubleValue, GUILayout.MaxWidth(100));
                break;

            case LayerFilterOperationType.Contains:
                property.FindPropertyRelative("PropertyValue").stringValue = EditorGUILayout.TextField(property.FindPropertyRelative("PropertyValue").stringValue, GUILayout.MaxWidth(150));
                break;

            case LayerFilterOperationType.IsInRange:
                property.FindPropertyRelative("Min").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Min").doubleValue, GUILayout.MaxWidth(100));
                property.FindPropertyRelative("Max").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Max").doubleValue, GUILayout.MaxWidth(100));
                break;

            default:
                break;
            }
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
            {
                vectorFilterOptions.RemoveFilter(index);
                propertyFilters.DeleteArrayElementAtIndex(index);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 16
0
        private void DrawPropertyDropDown(SerializedProperty originalProperty, SerializedProperty filterProperty)
        {
            var          selectedLayerName = originalProperty.FindPropertyRelative("_selectedLayerName").stringValue;
            AbstractMap  mapObject         = (AbstractMap)originalProperty.serializedObject.targetObject;
            TileJsonData tileJsonData      = mapObject.VectorData.GetTileJsonData();

            if (string.IsNullOrEmpty(selectedLayerName) || !tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName))
            {
                DrawWarningMessage();
                return;
            }

            var parsedString         = "no property selected";
            var descriptionString    = "no description available";
            var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName];

            _propertyNamesList = new List <string>(propertyDisplayNames);

            var propertyString = filterProperty.FindPropertyRelative("Key").stringValue;

            //check if the selection is valid
            if (_propertyNamesList.Contains(propertyString))
            {
                //if the layer contains the current layerstring, set it's index to match
                _propertyIndex = propertyDisplayNames.FindIndex(s => s.Equals(propertyString));

                //create guicontent for a valid layer
                _propertyNameContent = new GUIContent[_propertyNamesList.Count];
                for (int extIdx = 0; extIdx < _propertyNamesList.Count; extIdx++)
                {
                    var parsedPropertyString = _propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
                    _propertyNameContent[extIdx] = new GUIContent
                    {
                        text    = _propertyNamesList[extIdx],
                        tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
                    };
                }

                //display popup
                EditorGUI.BeginChangeCheck();
                _propertyIndex = EditorGUILayout.Popup(_propertyIndex, _propertyNameContent, GUILayout.MaxWidth(150));
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(filterProperty);
                }

                //set new string values based on selection
                parsedString      = _propertyNamesList[_propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
                descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString];
            }
            else
            {
                //if the selected layer isn't in the source, add a placeholder entry
                _propertyIndex = 0;
                _propertyNamesList.Insert(0, propertyString);

                //create guicontent for an invalid layer
                _propertyNameContent = new GUIContent[_propertyNamesList.Count];

                //first property gets a unique tooltip
                _propertyNameContent[0] = new GUIContent
                {
                    text    = _propertyNamesList[0],
                    tooltip = "Unavialable in Selected ILayer"
                };

                for (int extIdx = 1; extIdx < _propertyNamesList.Count; extIdx++)
                {
                    var parsedPropertyString = _propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
                    _propertyNameContent[extIdx] = new GUIContent
                    {
                        text    = _propertyNamesList[extIdx],
                        tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
                    };
                }

                //display popup
                EditorGUI.BeginChangeCheck();
                _propertyIndex = EditorGUILayout.Popup(_propertyIndex, _propertyNameContent, GUILayout.MaxWidth(150));
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(filterProperty);
                }

                //set new string values based on the offset
                parsedString      = _propertyNamesList[_propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
                descriptionString = "Unavailable in Selected ILayer.";
            }
            EditorGUI.BeginChangeCheck();
            filterProperty.FindPropertyRelative("Key").stringValue = parsedString;
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(filterProperty);
            }
            filterProperty.FindPropertyRelative("KeyDescription").stringValue = descriptionString;
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var kindProperty = property.FindPropertyRelative(extTypePropertyName);
            var displayNames = kindProperty.enumDisplayNames;
            int count        = kindProperty.enumDisplayNames.Length;

            if (!isGUIContentSet)
            {
                extentTypeContent = new GUIContent[count];
                for (int extIdx = 0; extIdx < count; extIdx++)
                {
                    extentTypeContent[extIdx] = new GUIContent
                    {
                        text    = displayNames[extIdx],
                        tooltip = EnumExtensions.Description((MapExtentType)extIdx),
                    };
                }
                isGUIContentSet = true;
            }
            // Draw label.
            var extentTypeLabel = new GUIContent
            {
                text    = label.text,
                tooltip = "Options to determine the geographic extent of the world for which the map tiles will be requested.",
            };

            EditorGUI.BeginChangeCheck();
            kindProperty.enumValueIndex = EditorGUILayout.Popup(extentTypeLabel, kindProperty.enumValueIndex, extentTypeContent, GUILayout.Height(_lineHeight));

            var kind = (MapExtentType)kindProperty.enumValueIndex;

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            EditorGUI.indentLevel++;

            GUILayout.Space(-_lineHeight);
            SerializedProperty defaultExtentsProp = property.FindPropertyRelative("defaultExtents");

            EditorGUI.BeginChangeCheck();

            switch (kind)
            {
            case MapExtentType.CameraBounds:
                GUILayout.Space(_lineHeight);
                EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("cameraBoundsOptions"), new GUIContent {
                    text = "CameraOptions-"
                });
                break;

            case MapExtentType.RangeAroundCenter:
                EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("rangeAroundCenterOptions"), new GUIContent {
                    text = "RangeAroundCenter"
                });
                break;

            case MapExtentType.RangeAroundTransform:
                GUILayout.Space(_lineHeight);
                EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("rangeAroundTransformOptions"), new GUIContent {
                    text = "RangeAroundTransform"
                });
                break;

            default:
                break;
            }
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(defaultExtentsProp);
            }
            EditorGUI.indentLevel--;
        }
Ejemplo n.º 18
0
        void DrawMapOptions(SerializedObject mapObject)
        {
            var property = mapObject.FindProperty("_options");

            if (!((AbstractMap)serializedObject.targetObject).IsAccessTokenValid)
            {
                EditorGUILayout.HelpBox("Invalid Access Token. Please add a valid access token using the Mapbox  > Setup Menu", MessageType.Error);
            }

            EditorGUILayout.LabelField("Location ", GUILayout.Height(_lineHeight));

            EditorGUILayout.PropertyField(property.FindPropertyRelative("locationOptions"));


            var extentOptions     = property.FindPropertyRelative("extentOptions");
            var extentOptionsType = extentOptions.FindPropertyRelative("extentType");


            if ((MapExtentType)extentOptionsType.enumValueIndex == MapExtentType.Custom)
            {
                var tileProviderProperty = mapObject.FindProperty("_tileProvider");
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(extentOptionsType);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(extentOptions);
                }
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(tileProviderProperty);
                EditorGUI.indentLevel--;
            }
            else
            {
                GUILayout.Space(-_lineHeight);
                EditorGUILayout.PropertyField(extentOptions);
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("_initializeOnStart"));

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others");
            if (ShowPosition)
            {
                GUILayout.Space(-_lineHeight);

                EditorGUI.BeginChangeCheck();
                var placementOptions = property.FindPropertyRelative("placementOptions");
                EditorGUILayout.PropertyField(placementOptions);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(placementOptions);
                }

                GUILayout.Space(-_lineHeight);

                EditorGUI.BeginChangeCheck();
                var scalingOptions = property.FindPropertyRelative("scalingOptions");
                EditorGUILayout.PropertyField(scalingOptions);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(scalingOptions);
                }

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(property.FindPropertyRelative("loadingTexture"));
                EditorGUILayout.PropertyField(property.FindPropertyRelative("tileMaterial"));
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(property);
                }
            }
        }
        void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty, SerializedProperty property)
        {
            var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");

            var subLayerName    = subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue;
            var visualizerLayer = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
            var subLayerType    = PresetSubLayerPropertiesFetcher.GetPresetTypeFromLayerName(visualizerLayer);

            GUILayout.Space(-_lineHeight);
            layerProperty.FindPropertyRelative("presetFeatureType").intValue = (int)subLayerType;

            GUILayout.Space(_lineHeight);
            //*********************** LAYER NAME BEGINS ***********************************//
            VectorPrimitiveType primitiveTypeProp = (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex;

            var         serializedMapObject = property.serializedObject;
            AbstractMap mapObject           = (AbstractMap)serializedMapObject.targetObject;

            tileJsonData = mapObject.VectorData.GetTileJsonData();

            var layerDisplayNames = tileJsonData.LayerDisplayNames;

            EditorGUI.BeginChangeCheck();
            DrawLayerName(subLayerCoreOptions, layerDisplayNames);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(subLayerCoreOptions);
            }
            //*********************** LAYER NAME ENDS ***********************************//

            EditorGUI.indentLevel++;

            //*********************** FILTERS SECTION BEGINS ***********************************//
            var filterOptions = layerProperty.FindPropertyRelative("filterOptions");

            filterOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
            GUILayout.Space(-_lineHeight);
            EditorGUILayout.PropertyField(filterOptions, new GUIContent("Filters"));
            //*********************** FILTERS SECTION ENDS ***********************************//



            //*********************** MODELING SECTION BEGINS ***********************************//
            _modelingSectionDrawer.DrawUI(subLayerCoreOptions, layerProperty, primitiveTypeProp);
            //*********************** MODELING SECTION ENDS ***********************************//


            //*********************** TEXTURING SECTION BEGINS ***********************************//
            if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
            {
                GUILayout.Space(-_lineHeight);
                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions"));
            }
            //*********************** TEXTURING SECTION ENDS ***********************************//


            //*********************** GAMEPLAY SECTION BEGINS ***********************************//
            _behaviorModifierSectionDrawer.DrawUI(layerProperty, primitiveTypeProp, sourceType);
            //*********************** GAMEPLAY SECTION ENDS ***********************************//

            EditorGUI.indentLevel--;
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var sourceTypeProperty = property.FindPropertyRelative("sourceType");
            var sourceTypeValue    = (ImagerySourceType)sourceTypeProperty.enumValueIndex;

            var displayNames = sourceTypeProperty.enumDisplayNames;
            int count        = sourceTypeProperty.enumDisplayNames.Length;

            if (!isGUIContentSet)
            {
                sourceTypeContent = new GUIContent[count];
                for (int extIdx = 0; extIdx < count; extIdx++)
                {
                    sourceTypeContent[extIdx] = new GUIContent
                    {
                        text    = displayNames[extIdx],
                        tooltip = EnumExtensions.Description((ImagerySourceType)extIdx),
                    };
                }
                isGUIContentSet = true;
            }

            // Draw label.
            var sourceTypeLabel = new GUIContent {
                text = "Data Source", tooltip = "Source tileset for Imagery."
            };

            EditorGUI.BeginChangeCheck();
            sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }
            sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex;

            var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions");
            var layerSourceProperty   = sourceOptionsProperty.FindPropertyRelative("layerSource");
            var layerSourceId         = layerSourceProperty.FindPropertyRelative("Id");

            EditorGUI.BeginChangeCheck();

            switch (sourceTypeValue)
            {
            case ImagerySourceType.MapboxStreets:
            case ImagerySourceType.MapboxOutdoors:
            case ImagerySourceType.MapboxDark:
            case ImagerySourceType.MapboxLight:
            case ImagerySourceType.MapboxSatellite:
            case ImagerySourceType.MapboxSatelliteStreet:
                var sourcePropertyValue = MapboxDefaultImagery.GetParameters(sourceTypeValue);
                layerSourceId.stringValue = sourcePropertyValue.Id;
                GUI.enabled = false;
                EditorGUILayout.PropertyField(sourceOptionsProperty, _tilesetIdGui);
                GUI.enabled = true;
                break;

            case ImagerySourceType.Custom:
                EditorGUILayout.PropertyField(sourceOptionsProperty, new GUIContent {
                    text = "Tileset Id / Style URL", tooltip = _tilesetIdGui.tooltip
                });
                break;

            case ImagerySourceType.None:
                break;

            default:
                break;
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            if (sourceTypeValue != ImagerySourceType.None)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(property.FindPropertyRelative("rasterOptions"));
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(property);
                }
            }
        }
Ejemplo n.º 21
0
        void DrawMapLayerOptions()
        {
            var vectorDataProperty           = serializedObject.FindProperty("_vectorData");
            var layerProperty                = vectorDataProperty.FindPropertyRelative("_layerProperty");
            var layerSourceProperty          = layerProperty.FindPropertyRelative("sourceOptions");
            var sourceTypeProperty           = layerProperty.FindPropertyRelative("_sourceType");
            VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
            var    layerSourceId             = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id");
            string layerString               = layerSourceId.stringValue;
            var    isActiveProperty          = layerSourceProperty.FindPropertyRelative("isActive");

            var displayNames = sourceTypeProperty.enumDisplayNames;
            var names        = sourceTypeProperty.enumNames;
            int count        = sourceTypeProperty.enumDisplayNames.Length;

            if (!_isGUIContentSet)
            {
                _sourceTypeContent = new GUIContent[count];

                var index = 0;
                foreach (var name in names)
                {
                    _sourceTypeContent[index] = new GUIContent
                    {
                        text    = displayNames[index],
                        tooltip = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), name)).Description(),
                    };
                    index++;
                }
                //
                //				for (int extIdx = 0; extIdx < count; extIdx++)
                //				{
                //					_sourceTypeContent[extIdx] = new GUIContent
                //					{
                //						text = displayNames[extIdx],
                //						tooltip = ((VectorSourceType)extIdx).Description(),
                //					};
                //				}

                _isGUIContentSet = true;
            }

            EditorGUI.BeginChangeCheck();
            sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(new GUIContent
            {
                text    = "Data Source",
                tooltip = "Source tileset for Vector Data"
            }, sourceTypeProperty.enumValueIndex, _sourceTypeContent);

            //sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
            sourceTypeValue = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), names[sourceTypeProperty.enumValueIndex]));

            switch (sourceTypeValue)
            {
            case VectorSourceType.MapboxStreets:
            case VectorSourceType.MapboxStreetsV8:
            case VectorSourceType.MapboxStreetsWithBuildingIds:
            case VectorSourceType.MapboxStreetsV8WithBuildingIds:
                var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue);
                layerSourceId.stringValue = sourcePropertyValue.Id;
                GUI.enabled = false;
                EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui);
                GUI.enabled = true;
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.Custom:
                EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui);
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.None:
                isActiveProperty.boolValue = false;
                break;

            default:
                isActiveProperty.boolValue = false;
                break;
            }

            if (sourceTypeValue != VectorSourceType.None)
            {
                var isStyleOptimized = layerProperty.FindPropertyRelative("useOptimizedStyle");
                EditorGUILayout.PropertyField(isStyleOptimized);

                if (isStyleOptimized.boolValue)
                {
                    EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("optimizedStyle"), new GUIContent("Style Options"));
                }
                GUILayout.Space(-_lineHeight);
                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("performanceOptions"), new GUIContent("Perfomance Options"));
            }

            EditorGUILayout.Space();
            ShowSepartor();

            _vectorLayerDrawer.DrawUI(layerProperty);

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(layerProperty);
            }
        }
Ejemplo n.º 22
0
        private void DrawMeshModifiers(SerializedProperty property)
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField(new GUIContent
            {
                text    = "Mesh Modifiers",
                tooltip = "Modifiers that manipulate the features mesh. "
            });

            var meshfac = property.FindPropertyRelative("MeshModifiers");

            for (int i = 0; i < meshfac.arraySize; i++)
            {
                var ind = i;
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.BeginVertical();
                meshfac.GetArrayElementAtIndex(ind).objectReferenceValue =
                    EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false)
                    as ScriptableObject;

                EditorGUILayout.EndVertical();

                if (GUILayout.Button(new GUIContent("x"), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
                {
                    bool elementWasDeleted = false;
                    if (meshfac.arraySize > 0)
                    {
                        meshfac.DeleteArrayElementAtIndex(ind);
                        elementWasDeleted = true;
                    }
                    if (meshfac.arraySize > 0)
                    {
                        meshfac.DeleteArrayElementAtIndex(ind);
                    }
                    if (elementWasDeleted)
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUI.indentLevel++;
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(EditorGUI.indentLevel * 12);
            Rect buttonRect = GUILayoutUtility.GetLastRect();

            if (GUILayout.Button(new GUIContent("Add New"), (GUIStyle)"minibuttonleft"))
            {
                PopupWindow.Show(buttonRect, new PopupSelectionMenu(typeof(MeshModifier), meshfac));
                if (Event.current.type == EventType.Repaint)
                {
                    buttonRect = GUILayoutUtility.GetLastRect();
                }
            }

            if (GUILayout.Button(new GUIContent("Add Existing"), (GUIStyle)"minibuttonright"))
            {
                ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac, -1, null, property);
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel--;
        }
Ejemplo n.º 23
0
        void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty, SerializedProperty property)
        {
            var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");
            //var layerName = layerProperty.FindPropertyRelative("coreOptions.layerName");
            //var roadLayerName = layerProperty.FindPropertyRelative("roadLayer");
            //var landuseLayerName = layerProperty.FindPropertyRelative("landuseLayer");


            var subLayerName    = subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue;
            var visualizerLayer = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
            var subLayerType    = PresetSubLayerPropertiesFetcher.GetPresetTypeFromLayerName(visualizerLayer);

            //var maskValue = layerProperty.FindPropertyRelative("_maskValue");
            //var selectedTypes = layerProperty.FindPropertyRelative("selectedTypes");

            GUILayout.Space(-_lineHeight);
            layerProperty.FindPropertyRelative("presetFeatureType").intValue = (int)subLayerType;
            //EditorGUILayout.LabelField("Sub-type : " + "Highway", visualizerNameAndType);
            GUILayout.Space(_lineHeight);
            //*********************** LAYER NAME BEGINS ***********************************//
            VectorPrimitiveType primitiveTypeProp = (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex;

            var         serializedMapObject = property.serializedObject;
            AbstractMap mapObject           = (AbstractMap)serializedMapObject.targetObject;

            tileJsonData = mapObject.VectorData.GetTileJsonData();

            var layerDisplayNames = tileJsonData.LayerDisplayNames;

            EditorGUI.BeginChangeCheck();
            DrawLayerName(subLayerCoreOptions, layerDisplayNames);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(subLayerCoreOptions);
            }
            //*********************** LAYER NAME ENDS ***********************************//

            //*********************** TYPE DROPDOWN BEGINS ***********************************//
            //if (_streetsV7TileStats == null || subTypeValues == null)
            //{
            //	subTypeValues = GetSubTypeValues(layerProperty, visualizerLayer, sourceType);
            //}

            //if ((layerName.stringValue == roadLayerName.stringValue || layerName.stringValue == landuseLayerName.stringValue) && subTypeValues!=null)
            //{
            //	maskValue.intValue = EditorGUILayout.MaskField("Type",maskValue.intValue, subTypeValues);
            //	string selectedOptions = string.Empty;
            //	for (int i = 0; i < subTypeValues.Length; i++)
            //	{
            //		if ((maskValue.intValue & (1 << i)) == (1 << i))
            //		{
            //			if (string.IsNullOrEmpty(selectedOptions))
            //			{
            //				selectedOptions = subTypeValues[i];
            //				continue;
            //			}
            //			selectedOptions += "," + subTypeValues[i];
            //		}
            //	}
            //	selectedTypes.stringValue = selectedOptions;
            //}
            //*********************** TYPE DROPDOWN ENDS ***********************************//

            EditorGUI.indentLevel++;

            //*********************** FILTERS SECTION BEGINS ***********************************//
            var filterOptions = layerProperty.FindPropertyRelative("filterOptions");

            filterOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
            GUILayout.Space(-_lineHeight);
            EditorGUILayout.PropertyField(filterOptions, new GUIContent("Filters"));
            //*********************** FILTERS SECTION ENDS ***********************************//



            //*********************** MODELING SECTION BEGINS ***********************************//
            _modelingSectionDrawer.DrawUI(subLayerCoreOptions, layerProperty, primitiveTypeProp);
            //*********************** MODELING SECTION ENDS ***********************************//


            //*********************** TEXTURING SECTION BEGINS ***********************************//
            if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
            {
                GUILayout.Space(-_lineHeight);
                EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions"));
            }
            //*********************** TEXTURING SECTION ENDS ***********************************//


            //*********************** GAMEPLAY SECTION BEGINS ***********************************//
            _behaviorModifierSectionDrawer.DrawUI(layerProperty, primitiveTypeProp, sourceType);
            //*********************** GAMEPLAY SECTION ENDS ***********************************//

            EditorGUI.indentLevel--;
        }
Ejemplo n.º 24
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            GUILayout.Space(-_lineHeight);
            var prefabItemCoreOptions = property.FindPropertyRelative("coreOptions");

            GUILayout.Label(prefabItemCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties");

            //Prefab Game Object
            EditorGUI.indentLevel++;
            var spawnPrefabOptions = property.FindPropertyRelative("spawnPrefabOptions");

            EditorGUILayout.PropertyField(spawnPrefabOptions);

            GUILayout.Space(1);
            EditorGUI.indentLevel--;

            //Prefab Locations title
            GUILayout.Label(prefabLocationsTitle);

            //FindBy drop down
            EditorGUILayout.BeginHorizontal();

            var findByProp = property.FindPropertyRelative("findByType");

            var displayNames = findByProp.enumDisplayNames;
            int count        = findByProp.enumDisplayNames.Length;

            if (!isGUIContentSet)
            {
                findByPropContent = new GUIContent[count];
                for (int extIdx = 0; extIdx < count; extIdx++)
                {
                    findByPropContent[extIdx] = new GUIContent
                    {
                        text    = displayNames[extIdx],
                        tooltip = ((LocationPrefabFindBy)extIdx).Description(),
                    };
                }
                isGUIContentSet = true;
            }

            EditorGUI.indentLevel++;

            EditorGUI.BeginChangeCheck();
            findByProp.enumValueIndex = EditorGUILayout.Popup(findByDropDown, findByProp.enumValueIndex, findByPropContent);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            EditorGUILayout.EndHorizontal();

            switch ((LocationPrefabFindBy)findByProp.enumValueIndex)
            {
            case (LocationPrefabFindBy.MapboxCategory):
                ShowCategoryOptions(property);
                break;

            case (LocationPrefabFindBy.AddressOrLatLon):
                ShowAddressOrLatLonUI(property);
                break;

            case (LocationPrefabFindBy.POIName):
                ShowPOINames(property);
                break;

            default:
                break;
            }
            EditorGUI.indentLevel--;
        }
        private void DrawPropertyName(SerializedProperty property, Rect position, string selectedLayerName)
        {
            var parsedString      = "No property selected";
            var descriptionString = "No description available";

            if (string.IsNullOrEmpty(selectedLayerName) || tileJsonData == null || !tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName))
            {
                DrawWarningMessage(position);
            }
            else
            {
                var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName];
                _propertyNamesList = new List <string>(propertyDisplayNames);

                //check if the selection is valid
                var propertyString = property.FindPropertyRelative("propertyName").stringValue;
                if (_propertyNamesList.Contains(propertyString))
                {
                    //if the layer contains the current layerstring, set it's index to match
                    _propertyIndex = propertyDisplayNames.FindIndex(s => s.Equals(propertyString));


                    //create guicontent for a valid layer
                    _propertyNameContent = new GUIContent[_propertyNamesList.Count];
                    for (int extIdx = 0; extIdx < _propertyNamesList.Count; extIdx++)
                    {
                        var parsedPropertyString = _propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
                        _propertyNameContent[extIdx] = new GUIContent
                        {
                            text    = _propertyNamesList[extIdx],
                            tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
                        };
                    }

                    //display popup
                    var propertyNameLabel = new GUIContent {
                        text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion"
                    };

                    EditorGUI.BeginChangeCheck();
                    _propertyIndex = EditorGUILayout.Popup(propertyNameLabel, _propertyIndex, _propertyNameContent);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }

                    //set new string values based on selection
                    parsedString      = _propertyNamesList[_propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
                    descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString];
                }
                else
                {
                    //if the selected layer isn't in the source, add a placeholder entry
                    _propertyIndex = 0;
                    _propertyNamesList.Insert(0, propertyString);

                    //create guicontent for an invalid layer
                    _propertyNameContent = new GUIContent[_propertyNamesList.Count];

                    //first property gets a unique tooltip
                    _propertyNameContent[0] = new GUIContent
                    {
                        text    = _propertyNamesList[0],
                        tooltip = "Unavialable in Selected Layer"
                    };

                    for (int extIdx = 1; extIdx < _propertyNamesList.Count; extIdx++)
                    {
                        var parsedPropertyString = _propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
                        _propertyNameContent[extIdx] = new GUIContent
                        {
                            text    = _propertyNamesList[extIdx],
                            tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
                        };
                    }

                    //display popup
                    var propertyNameLabel = new GUIContent {
                        text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion"
                    };

                    EditorGUI.BeginChangeCheck();
                    _propertyIndex = EditorGUILayout.Popup(propertyNameLabel, _propertyIndex, _propertyNameContent);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }

                    //set new string values based on the offset
                    parsedString      = _propertyNamesList[_propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
                    descriptionString = "Unavailable in Selected Layer.";
                }

                property.FindPropertyRelative("propertyName").stringValue        = parsedString;
                property.FindPropertyRelative("propertyDescription").stringValue = descriptionString;
            }

            descriptionString = string.IsNullOrEmpty(descriptionString) ? "No description available" : descriptionString;

            var propertyDescriptionPrefixLabel = new GUIContent {
                text = "Property Description", tooltip = "Factual information about the selected property"
            };

            EditorGUILayout.LabelField(propertyDescriptionPrefixLabel, new GUIContent(descriptionString), (GUIStyle)"wordWrappedLabel");
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var extrusionTypeProperty = property.FindPropertyRelative("extrusionType");
            var displayNames          = extrusionTypeProperty.enumDisplayNames;
            int count = extrusionTypeProperty.enumDisplayNames.Length;

            if (!isGUIContentSet)
            {
                extrusionTypeContent = new GUIContent[count];
                for (int extIdx = 0; extIdx < count; extIdx++)
                {
                    extrusionTypeContent[extIdx] = new GUIContent
                    {
                        text    = displayNames[extIdx],
                        tooltip = EnumExtensions.Description((ExtrusionType)extIdx),
                    };
                }
                isGUIContentSet = true;
            }

            var extrusionTypeLabel = new GUIContent
            {
                text    = "Extrusion Type",
                tooltip = "Type of geometry extrusion"
            };

            EditorGUI.BeginChangeCheck();
            extrusionTypeProperty.enumValueIndex = EditorGUILayout.Popup(extrusionTypeLabel, extrusionTypeProperty.enumValueIndex, extrusionTypeContent);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            var sourceTypeValue = (Unity.Map.ExtrusionType)extrusionTypeProperty.enumValueIndex;

            var minHeightProperty = property.FindPropertyRelative("minimumHeight");
            var maxHeightProperty = property.FindPropertyRelative("maximumHeight");

            var extrusionGeometryType = property.FindPropertyRelative("extrusionGeometryType");
            var extrusionGeometryGUI  = new GUIContent {
                text = "Geometry Type", tooltip = EnumExtensions.Description((Unity.Map.ExtrusionGeometryType)extrusionGeometryType.enumValueIndex)
            };

            EditorGUI.indentLevel++;

            EditorGUI.BeginChangeCheck();

            switch (sourceTypeValue)
            {
            case Unity.Map.ExtrusionType.None:
                break;

            case Unity.Map.ExtrusionType.PropertyHeight:
                EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
                DrawPropertyDropDown(property, position);
                break;

            case Unity.Map.ExtrusionType.MinHeight:
                EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
                DrawPropertyDropDown(property, position);
                break;

            case Unity.Map.ExtrusionType.MaxHeight:
                EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
                DrawPropertyDropDown(property, position);
                break;

            case Unity.Map.ExtrusionType.RangeHeight:
                EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
                DrawPropertyDropDown(property, position);
                EditorGUILayout.PropertyField(minHeightProperty);
                EditorGUILayout.PropertyField(maxHeightProperty);
                if (minHeightProperty.floatValue > maxHeightProperty.floatValue)
                {
                    EditorGUILayout.HelpBox("Maximum Height less than Minimum Height!", MessageType.Error);
                }
                break;

            case Unity.Map.ExtrusionType.AbsoluteHeight:
                EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI);
                EditorGUILayout.PropertyField(maxHeightProperty, new GUIContent {
                    text = "Height"
                });
                break;

            default:
                break;
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent {
                text = "Scale Factor"
            });
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            EditorGUI.indentLevel--;
        }
Ejemplo n.º 27
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            objectId = property.serializedObject.targetObject.GetInstanceID().ToString();

            var sourceTypeProperty = property.FindPropertyRelative("sourceType");

            var displayNames = sourceTypeProperty.enumDisplayNames;
            int count        = sourceTypeProperty.enumDisplayNames.Length;

            if (!isGUIContentSet)
            {
                sourceTypeContent = new GUIContent[count];
                for (int extIdx = 0; extIdx < count; extIdx++)
                {
                    sourceTypeContent[extIdx] = new GUIContent
                    {
                        text    = displayNames[extIdx],
                        tooltip = ((ElevationSourceType)extIdx).Description(),
                    };
                }
                isGUIContentSet = true;
            }
            var sourceTypeLabel = new GUIContent {
                text = "Data Source", tooltip = "Source tileset for Terrain."
            };

            EditorGUI.BeginChangeCheck();
            sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            var sourceTypeValue = (ElevationSourceType)sourceTypeProperty.enumValueIndex;

            var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions");
            var layerSourceProperty   = sourceOptionsProperty.FindPropertyRelative("layerSource");
            var layerSourceId         = layerSourceProperty.FindPropertyRelative("Id");

            EditorGUI.BeginChangeCheck();

            switch (sourceTypeValue)
            {
            case ElevationSourceType.MapboxTerrain:
                var sourcePropertyValue = MapboxDefaultElevation.GetParameters(sourceTypeValue);
                layerSourceId.stringValue = sourcePropertyValue.Id;
                GUI.enabled = false;
                EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui);
                GUI.enabled = true;
                break;

            case ElevationSourceType.Custom:
                layerSourceId.stringValue = string.IsNullOrEmpty(CustomSourceMapId) ? MapboxDefaultElevation.GetParameters(ElevationSourceType.MapboxTerrain).Id : CustomSourceMapId;
                EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui);
                CustomSourceMapId = layerSourceId.stringValue;
                break;

            default:
                break;
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            var elevationLayerType = property.FindPropertyRelative("elevationLayerType");

            if (sourceTypeValue == ElevationSourceType.None)
            {
                GUI.enabled = false;
                elevationLayerType.enumValueIndex = (int)ElevationLayerType.FlatTerrain;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(property.FindPropertyRelative("elevationLayerType"), new GUIContent {
                text = elevationLayerType.displayName, tooltip = ((ElevationLayerType)elevationLayerType.enumValueIndex).Description()
            });
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            if (sourceTypeValue == ElevationSourceType.None)
            {
                GUI.enabled = true;
            }

            GUILayout.Space(-lineHeight);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(property.FindPropertyRelative("colliderOptions"), true);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property.FindPropertyRelative("colliderOptions"));
            }
            GUILayout.Space(2 * -lineHeight);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(property.FindPropertyRelative("requiredOptions"), true);
            GUILayout.Space(-lineHeight);
            if (EditorGUI.EndChangeCheck())
            {
                EditorHelper.CheckForModifiedProperty(property);
            }

            ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others");

            if (ShowPosition)
            {
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.PropertyField(property.FindPropertyRelative("modificationOptions"), true);

                EditorGUILayout.PropertyField(property.FindPropertyRelative("sideWallOptions"), true);

                EditorGUILayout.PropertyField(property.FindPropertyRelative("unityLayerOptions"), true);

                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(property);
                }
            }
        }
        public void DrawUI(SerializedProperty property)
        {
            objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
            var         serializedMapObject = property.serializedObject;
            AbstractMap mapObject           = (AbstractMap)serializedMapObject.targetObject;

            tileJSONData = mapObject.VectorData.GetTileJsonData();

            var sourceTypeProperty = property.FindPropertyRelative("_sourceType");
            var sourceTypeValue    = (VectorSourceType)sourceTypeProperty.enumValueIndex;

            var displayNames = sourceTypeProperty.enumDisplayNames;
            var names        = sourceTypeProperty.enumNames;
            int count        = sourceTypeProperty.enumDisplayNames.Length;

            if (!_isGUIContentSet)
            {
                _sourceTypeContent = new GUIContent[count];

                var index = 0;
                foreach (var name in names)
                {
                    _sourceTypeContent[index] = new GUIContent
                    {
                        text    = displayNames[index],
                        tooltip = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), name)).Description(),
                    };
                    index++;
                }

                //				for (int index0 = 0; index0 < count; index0++)
                //				{
                //					_sourceTypeContent[index0] = new GUIContent
                //					{
                //						text = displayNames[index0],
                //						tooltip = ((VectorSourceType)index0).Description(),
                //					};
                //				}
                _isGUIContentSet = true;
            }

            //sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
            sourceTypeValue = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), names[sourceTypeProperty.enumValueIndex]));
            var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions");
            var layerSourceProperty   = sourceOptionsProperty.FindPropertyRelative("layerSource");
            var layerSourceId         = layerSourceProperty.FindPropertyRelative("Id");
            var isActiveProperty      = sourceOptionsProperty.FindPropertyRelative("isActive");

            switch (sourceTypeValue)
            {
            case VectorSourceType.MapboxStreets:
            case VectorSourceType.MapboxStreetsV8:
            case VectorSourceType.MapboxStreetsWithBuildingIds:
            case VectorSourceType.MapboxStreetsV8WithBuildingIds:
                var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue);
                layerSourceId.stringValue = sourcePropertyValue.Id;
                GUI.enabled = false;
                if (_isInitialized)
                {
                    LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
                }
                else
                {
                    _isInitialized = true;
                }
                if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded)
                {
                    EditorGUILayout.HelpBox("Invalid Tileset Id / There might be a problem with the internet connection.", MessageType.Error);
                }
                GUI.enabled = true;
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.Custom:
                if (_isInitialized)
                {
                    string test = layerSourceId.stringValue;
                    LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
                }
                else
                {
                    _isInitialized = true;
                }
                if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded)
                {
                    EditorGUILayout.HelpBox("Invalid Tileset Id / There might be a problem with the internet connection.", MessageType.Error);
                }
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.None:
                isActiveProperty.boolValue = false;
                break;

            default:
                isActiveProperty.boolValue = false;
                break;
            }

            if (sourceTypeValue != VectorSourceType.None)
            {
                EditorGUILayout.LabelField(new GUIContent
                {
                    text    = "Map Features",
                    tooltip = "Visualizers for vector features contained in a layer. "
                });

                var subLayerArray = property.FindPropertyRelative("vectorSubLayers");

                var layersRect = EditorGUILayout.GetControlRect(GUILayout.MinHeight(Mathf.Max(subLayerArray.arraySize + 1, 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight),
                                                                GUILayout.MaxHeight((subLayerArray.arraySize + 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight));

                if (!m_Initialized)
                {
                    bool firstInit   = m_MultiColumnHeaderState == null;
                    var  headerState = FeatureSubLayerTreeView.CreateDefaultMultiColumnHeaderState();
                    if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
                    {
                        MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
                    }
                    m_MultiColumnHeaderState = headerState;

                    var multiColumnHeader = new FeatureSectionMultiColumnHeader(headerState);

                    if (firstInit)
                    {
                        multiColumnHeader.ResizeToFit();
                    }

                    treeModel = new TreeModel <FeatureTreeElement>(GetData(subLayerArray));
                    if (m_TreeViewState == null)
                    {
                        m_TreeViewState = new TreeViewState();
                    }

                    if (layerTreeView == null)
                    {
                        layerTreeView = new FeatureSubLayerTreeView(m_TreeViewState, multiColumnHeader, treeModel);
                    }
                    layerTreeView.multiColumnHeader = multiColumnHeader;
                    m_Initialized = true;
                }
                layerTreeView.Layers = subLayerArray;
                layerTreeView.Reload();
                layerTreeView.OnGUI(layersRect);

                if (layerTreeView.hasChanged)
                {
                    EditorHelper.CheckForModifiedProperty(property);
                    layerTreeView.hasChanged = false;
                }

                selectedLayers = layerTreeView.GetSelection();

                //if there are selected elements, set the selection index at the first element.
                //if not, use the Selection index to persist the selection at the right index.
                if (selectedLayers.Count > 0)
                {
                    //ensure that selectedLayers[0] isn't out of bounds
                    if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature > subLayerArray.arraySize - 1)
                    {
                        selectedLayers[0] = subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature;
                    }

                    SelectionIndex = selectedLayers[0];
                }
                else
                {
                    if (SelectionIndex > 0 && (SelectionIndex - FeatureSubLayerTreeView.uniqueIdFeature <= subLayerArray.arraySize - 1))
                    {
                        selectedLayers = new int[1] {
                            SelectionIndex
                        };
                        layerTreeView.SetSelection(selectedLayers);
                    }
                }

                GUILayout.Space(EditorGUIUtility.singleLineHeight);

                EditorGUILayout.BeginHorizontal();
                GenericMenu menu = new GenericMenu();
                foreach (var name in Enum.GetNames(typeof(PresetFeatureType)))
                {
                    menu.AddItem(new GUIContent()
                    {
                        text = name
                    }, false, FetchPresetProperties, name);
                }
                GUILayout.Space(0);                 // do not remove this line; it is needed for the next line to work
                Rect rect = GUILayoutUtility.GetLastRect();
                rect.y += 2 * _lineHeight / 3;

                if (EditorGUILayout.DropdownButton(new GUIContent {
                    text = "Add Feature"
                }, FocusType.Passive, (GUIStyle)"minibuttonleft"))
                {
                    menu.DropDown(rect);
                }

                //Assign subLayerProperties after fetching it from the presets class. This happens everytime an element is added
                if (subLayerProperties != null)
                {
                    subLayerArray.arraySize++;
                    var subLayer = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1);
                    SetSubLayerProps(subLayer);

                    //Refreshing the tree
                    layerTreeView.Layers = subLayerArray;
                    layerTreeView.AddElementToTree(subLayer);
                    layerTreeView.Reload();

                    selectedLayers = new int[1] {
                        subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature
                    };
                    layerTreeView.SetSelection(selectedLayers);
                    subLayerProperties = null;                     // setting this to null so that the if block is not called again

                    if (EditorHelper.DidModifyProperty(property))
                    {
                        isLayerAdded = true;
                    }
                }

                if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright"))
                {
                    foreach (var index in selectedLayers.OrderByDescending(i => i))
                    {
                        if (layerTreeView != null)
                        {
                            var subLayer = subLayerArray.GetArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdFeature);

                            VectorLayerProperties    vectorLayerProperties    = (VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property);
                            VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(subLayer);

                            vectorLayerProperties.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs {
                                property = vectorSubLayerProperties
                            });

                            layerTreeView.RemoveItemFromTree(index);
                            subLayerArray.DeleteArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdFeature);
                            layerTreeView.treeModel.SetData(GetData(subLayerArray));
                        }
                    }

                    selectedLayers = new int[0];
                    layerTreeView.SetSelection(selectedLayers);
                }

                EditorGUILayout.EndHorizontal();

                GUILayout.Space(EditorGUIUtility.singleLineHeight);

                if (selectedLayers.Count == 1 && subLayerArray.arraySize != 0 && selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature >= 0)
                {
                    //ensure that selectedLayers[0] isn't out of bounds
                    if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature > subLayerArray.arraySize - 1)
                    {
                        selectedLayers[0] = subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature;
                    }

                    SelectionIndex = selectedLayers[0];

                    var layerProperty = subLayerArray.GetArrayElementAtIndex(SelectionIndex - FeatureSubLayerTreeView.uniqueIdFeature);

                    layerProperty.isExpanded = true;
                    var  subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");
                    bool isLayerActive       = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue;
                    if (!isLayerActive)
                    {
                        GUI.enabled = false;
                    }

                    DrawLayerVisualizerProperties(sourceTypeValue, layerProperty, property);

                    if (!isLayerActive)
                    {
                        GUI.enabled = true;
                    }
                }
                else
                {
                    GUILayout.Label("Select a visualizer to see properties");
                }
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            objectId = property.serializedObject.targetObject.GetInstanceID().ToString();

            showTexturing = EditorGUILayout.Foldout(showTexturing, new GUIContent {
                text = "Texturing", tooltip = "Material options to texture the generated building geometry"
            });
            if (showTexturing)
            {
                LoadDefaultStyleIcons();
                EditorGUI.BeginProperty(position, label, property);

                var styleTypeLabel = new GUIContent {
                    text = "Style Type", tooltip = "Texturing style for feature; choose from sample style or create your own by choosing Custom. "
                };
                var styleType = property.FindPropertyRelative("style");

                GUIContent[] styleTypeGuiContent = new GUIContent[styleType.enumDisplayNames.Length];
                for (int i = 0; i < styleType.enumDisplayNames.Length; i++)
                {
                    styleTypeGuiContent[i] = new GUIContent
                    {
                        text = styleType.enumDisplayNames[i]
                    };
                }

                EditorGUI.BeginChangeCheck();
                styleType.enumValueIndex = EditorGUILayout.Popup(styleTypeLabel, styleType.enumValueIndex, styleTypeGuiContent);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorHelper.CheckForModifiedProperty(property);
                }

                EditorGUI.indentLevel++;
                if ((StyleTypes)styleType.enumValueIndex != StyleTypes.Custom)
                {
                    GUILayout.BeginHorizontal();

                    var style = (StyleTypes)styleType.enumValueIndex;

                    Texture2D thumbnailTexture = (Texture2D)_styleIconBundles[style].texture;

                    if ((StyleTypes)styleType.enumValueIndex == StyleTypes.Simple)
                    {
                        var samplePaletteType = property.FindPropertyRelative("samplePalettes");
                        var palette           = (SamplePalettes)samplePaletteType.enumValueIndex;
                        thumbnailTexture = (Texture2D)_paletteIconBundles[palette].texture;
                    }

                    string descriptionLabel = EnumExtensions.Description(style);
                    EditorGUILayout.LabelField(new GUIContent(" ", thumbnailTexture), Constants.GUI.Styles.EDITOR_TEXTURE_THUMBNAIL_STYLE, GUILayout.Height(60), GUILayout.Width(EditorGUIUtility.labelWidth - 60));
                    EditorGUILayout.TextArea(descriptionLabel, (GUIStyle)"wordWrappedLabel");

                    GUILayout.EndHorizontal();

                    EditorGUI.BeginChangeCheck();

                    switch ((StyleTypes)styleType.enumValueIndex)
                    {
                    case StyleTypes.Simple:
                        var samplePaletteType      = property.FindPropertyRelative("samplePalettes");
                        var samplePaletteTypeLabel = new GUIContent {
                            text = "Palette Type", tooltip = "Palette type for procedural colorization; choose from sample palettes or create your own by choosing Custom. "
                        };

                        GUIContent[] samplePaletteTypeGuiContent = new GUIContent[samplePaletteType.enumDisplayNames.Length];
                        for (int i = 0; i < samplePaletteType.enumDisplayNames.Length; i++)
                        {
                            samplePaletteTypeGuiContent[i] = new GUIContent
                            {
                                text = samplePaletteType.enumDisplayNames[i]
                            };
                        }
                        samplePaletteType.enumValueIndex = EditorGUILayout.Popup(samplePaletteTypeLabel, samplePaletteType.enumValueIndex, samplePaletteTypeGuiContent);
                        break;

                    case StyleTypes.Light:
                        property.FindPropertyRelative("lightStyleOpacity").floatValue = EditorGUILayout.Slider("Opacity", property.FindPropertyRelative("lightStyleOpacity").floatValue, 0.0f, 1.0f);
                        break;

                    case StyleTypes.Dark:
                        property.FindPropertyRelative("darkStyleOpacity").floatValue = EditorGUILayout.Slider("Opacity", property.FindPropertyRelative("darkStyleOpacity").floatValue, 0.0f, 1.0f);
                        break;

                    case StyleTypes.Color:
                        property.FindPropertyRelative("colorStyleColor").colorValue = EditorGUILayout.ColorField("Color", property.FindPropertyRelative("colorStyleColor").colorValue);
                        break;

                    default:
                        break;
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }
                }
                else
                {
                    var customStyleProperty = property.FindPropertyRelative("customStyleOptions");
                    var texturingType       = customStyleProperty.FindPropertyRelative("texturingType");

                    int valIndex         = texturingType.enumValueIndex == 0 ? 0 : texturingType.enumValueIndex + 1;
                    var texturingTypeGUI = new GUIContent {
                        text = "Texturing Type", tooltip = EnumExtensions.Description((UvMapType)valIndex)
                    };

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(texturingType, texturingTypeGUI);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }

                    var matList = customStyleProperty.FindPropertyRelative("materials");
                    if (matList.arraySize == 0)
                    {
                        matList.arraySize = 2;
                    }
                    GUILayout.Space(-lineHeight);

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(matList.GetArrayElementAtIndex(0), new GUIContent {
                        text = "Top Material", tooltip = "Unity material to use for extruded top/roof mesh. "
                    });
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }


                    GUILayout.Space(-lineHeight);

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(matList.GetArrayElementAtIndex(1), new GUIContent {
                        text = "Side Material", tooltip = "Unity material to use for extruded side/wall mesh. "
                    });
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }

                    EditorGUI.BeginChangeCheck();

                    if ((UvMapType)texturingType.enumValueIndex + 1 == UvMapType.Atlas)
                    {
                        var atlasInfo = customStyleProperty.FindPropertyRelative("atlasInfo");
                        EditorGUILayout.ObjectField(atlasInfo, new GUIContent {
                            text = "Altas Info", tooltip = "Atlas information scriptable object, this defines how the texture roof and wall texture atlases will be used.  "
                        });
                    }
                    if ((UvMapType)texturingType.enumValueIndex + 1 == UvMapType.AtlasWithColorPalette)
                    {
                        var atlasInfo = customStyleProperty.FindPropertyRelative("atlasInfo");
                        EditorGUILayout.ObjectField(atlasInfo, new GUIContent {
                            text = "Altas Info", tooltip = "Atlas information scriptable object, this defines how the texture roof and wall texture atlases will be used.  "
                        });

                        var colorPalette = customStyleProperty.FindPropertyRelative("colorPalette");
                        EditorGUILayout.ObjectField(colorPalette, new GUIContent {
                            text = "Color Palette", tooltip = "Color palette scriptable object, allows texture features to be procedurally colored at runtime. Requires materials that use the MapboxPerRenderer shader. "
                        });

                        EditorGUILayout.LabelField(new GUIContent {
                            text = "Note: Atlas With Color Palette requires materials that use the MapboxPerRenderer shader."
                        }, Constants.GUI.Styles.EDITOR_NOTE_STYLE);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }
                }
                EditorGUI.indentLevel--;
                EditorGUI.EndProperty();
            }
        }