diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs index 8b91fe6e8..51e7d07f2 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs @@ -16,17 +16,21 @@ public class GeocodeAttributeDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - float buttonWidth = EditorGUIUtility.singleLineHeight * 4; - - Rect fieldRect = new Rect(position.x, position.y, position.width - buttonWidth, EditorGUIUtility.singleLineHeight); - Rect buttonRect = new Rect(position.x + position.width - buttonWidth, position.y, buttonWidth, EditorGUIUtility.singleLineHeight); - - EditorGUI.PropertyField(fieldRect, property); + GUILayout.BeginHorizontal(); + if (string.IsNullOrEmpty(label.text)) + { - if (GUI.Button(buttonRect, searchButtonContent)) + property.stringValue = EditorGUILayout.TextField(property.stringValue); + } + else + { + property.stringValue = EditorGUILayout.TextField(label, property.stringValue); + } + if (GUILayout.Button(new GUIContent(searchButtonContent), (GUIStyle)"minibutton", GUILayout.MaxWidth(100))) { GeocodeAttributeSearchWindow.Open(property); } + GUILayout.EndHorizontal(); } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 18f722afa..70aef8650 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -103,7 +103,6 @@ bool ShowFeatures } } - bool ShowPosition { get @@ -136,25 +135,26 @@ string CustomSourceMapId bool _isGUIContentSet = false; GUIContent[] _sourceTypeContent; + static float _lineHeight = EditorGUIUtility.singleLineHeight; public override void OnInspectorGUI() { serializedObject.Update(); - GUILayout.BeginVertical(); + EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); ShowGeneral = EditorGUILayout.Foldout(ShowGeneral, new GUIContent { text = "GENERAL", tooltip = "Options related to map data" }); + if (ShowGeneral) { - EditorGUILayout.Space(); DrawMapOptions(serializedObject); } - ShowSepartor(); ShowImage = EditorGUILayout.Foldout(ShowImage, "IMAGE"); if (ShowImage) { + GUILayout.Space(-1.5f * _lineHeight); ShowSection(serializedObject.FindProperty("_imagery"), "_layerProperty"); } @@ -163,6 +163,7 @@ public override void OnInspectorGUI() ShowTerrain = EditorGUILayout.Foldout(ShowTerrain, "TERRAIN"); if (ShowTerrain) { + GUILayout.Space(-1.5f * _lineHeight); ShowSection(serializedObject.FindProperty("_terrain"), "_layerProperty"); } @@ -171,104 +172,7 @@ public override void OnInspectorGUI() ShowMapLayers = EditorGUILayout.Foldout(ShowMapLayers, "MAP LAYERS"); if (ShowMapLayers) { - EditorGUI.indentLevel++; - 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; - string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; - var layerSourceId = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id"); - string layerString = layerSourceId.stringValue; - var isActiveProperty = layerSourceProperty.FindPropertyRelative("isActive"); - - 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 = ((VectorSourceType)extIdx).Description(), - }; - } - - _isGUIContentSet = true; - } - - sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(new GUIContent - { - text = "Data Source", - tooltip = "Source tileset for Vector Data" - },sourceTypeProperty.enumValueIndex, _sourceTypeContent); - - sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; - - switch (sourceTypeValue) - { - case VectorSourceType.MapboxStreets: - case VectorSourceType.MapboxStreetsWithBuildingIds: - 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: - layerSourceId.stringValue = CustomSourceMapId; - EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui); - CustomSourceMapId = layerSourceId.stringValue; - 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")); - } - - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("performanceOptions"), new GUIContent("Perfomance Options")); - } - EditorGUILayout.Space(); - ShowSepartor(); - - ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST"); - if (ShowLocationPrefabs) - { - if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7)) - { - GUI.enabled = false; - EditorGUILayout.TextField(_requiredMapIdGui, streets_v7); - GUI.enabled = true; - ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties"); - } - else - { - EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source.", MessageType.Error); - } - } - ShowSepartor(); - ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES"); - if (ShowFeatures) - { - ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); - } - EditorGUI.indentLevel--; + DrawMapLayerOptions(); } GUILayout.EndVertical(); @@ -291,19 +195,22 @@ void DrawMapOptions(SerializedObject mapObject) { var property = mapObject.FindProperty("_options"); - EditorGUILayout.LabelField("Location "); + 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 test = mapObject.FindProperty("_tileProvider"); EditorGUILayout.PropertyField(extentOptionsType); + EditorGUI.indentLevel++; EditorGUILayout.PropertyField(test); + EditorGUI.indentLevel--; } else { + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(property.FindPropertyRelative("extentOptions")); } @@ -312,12 +219,116 @@ void DrawMapOptions(SerializedObject mapObject) ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others"); if (ShowPosition) { + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(property.FindPropertyRelative("placementOptions")); + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(property.FindPropertyRelative("scalingOptions")); EditorGUILayout.PropertyField(property.FindPropertyRelative("loadingTexture")); } } + void DrawMapLayerOptions() + { + //EditorGUI.indentLevel++; + 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; + string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; + var layerSourceId = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id"); + string layerString = layerSourceId.stringValue; + var isActiveProperty = layerSourceProperty.FindPropertyRelative("isActive"); + + 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 = ((VectorSourceType)extIdx).Description(), + }; + } + + _isGUIContentSet = true; + } + + sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(new GUIContent + { + text = "Data Source", + tooltip = "Source tileset for Vector Data" + }, sourceTypeProperty.enumValueIndex, _sourceTypeContent); + + sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; + + switch (sourceTypeValue) + { + case VectorSourceType.MapboxStreets: + case VectorSourceType.MapboxStreetsWithBuildingIds: + 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: + layerSourceId.stringValue = CustomSourceMapId; + EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui); + CustomSourceMapId = layerSourceId.stringValue; + 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(); + + ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST"); + if (ShowLocationPrefabs) + { + if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7)) + { + GUI.enabled = false; + EditorGUILayout.TextField(_requiredMapIdGui, streets_v7); + GUI.enabled = true; + ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties"); + } + else + { + EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source in the FEATURES section.", MessageType.Error); + } + } + + ShowSepartor(); + ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES"); + if (ShowFeatures) + { + ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); + } + } + void PresetLocationBased(SerializedProperty unifiedMap) { //Set diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CameraBoundsTileProviderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CameraBoundsTileProviderOptionsDrawer.cs index cc4858531..b69eb9548 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CameraBoundsTileProviderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CameraBoundsTileProviderOptionsDrawer.cs @@ -7,16 +7,22 @@ [CustomPropertyDrawer(typeof(CameraBoundsTileProviderOptions))] public class CameraBoundsTileProviderOptionsDrawer : PropertyDrawer { - static float lineHeight = EditorGUIUtility.singleLineHeight; + static float _lineHeight = EditorGUIUtility.singleLineHeight; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); var camera = property.FindPropertyRelative("camera"); var updateInterval = property.FindPropertyRelative("updateInterval"); - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), camera, new GUIContent { text = camera.displayName, tooltip = "Camera to control map extent." }); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), updateInterval, new GUIContent { text = updateInterval.displayName, tooltip = "Time in ms between map extent update." }); - EditorGUI.EndProperty(); + EditorGUILayout.PropertyField(camera, new GUIContent + { + text = camera.displayName, + tooltip = "Camera to control map extent." + }, GUILayout.Height(_lineHeight)); + EditorGUILayout.PropertyField(updateInterval, new GUIContent + { + text = updateInterval.displayName, + tooltip = "Time in ms between map extent update." + }, GUILayout.Height(_lineHeight)); + } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs index 4b57b213f..215a84363 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs @@ -11,28 +11,35 @@ public class ColliderOptionsDrawer : PropertyDrawer { static float lineHeight = EditorGUIUtility.singleLineHeight; + bool isGUIContentSet = false; + GUIContent[] colliderTypeContent; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Collider Type", tooltip = "The type of collider added to game objects in this layer." }); + var colliderTypeLabel = new GUIContent + { + text = "Collider Type", + tooltip = "The type of collider added to game objects in this layer." + }; var colliderTypeProperty = property.FindPropertyRelative("colliderType"); - List enumContent = new List(); - foreach(var enumValue in colliderTypeProperty.enumDisplayNames) + var displayNames = colliderTypeProperty.enumDisplayNames; + int count = colliderTypeProperty.enumDisplayNames.Length; + + if (!isGUIContentSet) { - var guiContent = new GUIContent { text = enumValue, tooltip = ((Unity.Map.ColliderType)colliderTypeProperty.enumValueIndex).Description()} ; - enumContent.Add(guiContent); + 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; } - EditorGUI.indentLevel--; - colliderTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, colliderTypeProperty.enumValueIndex, enumContent.ToArray()); - EditorGUI.indentLevel++; - EditorGUI.EndProperty(); - } - - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - return lineHeight; + colliderTypeProperty.enumValueIndex = EditorGUILayout.Popup(colliderTypeLabel, colliderTypeProperty.enumValueIndex, colliderTypeContent); } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index e38dc4d18..5bac41edb 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -3,57 +3,53 @@ using UnityEditor; using UnityEngine; using Mapbox.Unity.Map; + using Mapbox.VectorTile.ExtensionMethods; [CustomPropertyDrawer(typeof(CoreVectorLayerProperties))] public class CoreVectorLayerPropertiesDrawer : PropertyDrawer { static float lineHeight = EditorGUIUtility.singleLineHeight; + bool isGUIContentSet = false; + GUIContent[] primitiveTypeContent; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - // Draw label. var primitiveType = property.FindPropertyRelative("geometryType"); - var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Primitive Type", tooltip = "Primitive geometry type of the visualizer, allowed primitives - point, line, polygon." }); - EditorGUI.indentLevel--; - primitiveType.enumValueIndex = EditorGUI.Popup(typePosition, primitiveType.enumValueIndex, primitiveType.enumDisplayNames); - EditorGUI.indentLevel++; - - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("layerName")); - - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("snapToTerrain")); + var primitiveTypeLabel = new GUIContent + { + text = "Primitive Type", + tooltip = "Primitive geometry type of the visualizer, allowed primitives - point, line, polygon." + }; - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("groupFeatures")); + var displayNames = primitiveType.enumDisplayNames; + int count = primitiveType.enumDisplayNames.Length; - if ((VectorPrimitiveType)primitiveType.enumValueIndex == VectorPrimitiveType.Line) + if (!isGUIContentSet) { - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("lineWidth")); + 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; } + primitiveType.enumValueIndex = EditorGUILayout.Popup(primitiveTypeLabel, primitiveType.enumValueIndex, primitiveTypeContent); - EditorGUI.EndProperty(); - } + EditorGUILayout.PropertyField(property.FindPropertyRelative("layerName")); - /// - /// Gets the number of UI rows necessary to draw the property correctly, given it's primitive type. - /// - /// The property height. - /// Property. - /// Label. - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var sourceTypeProperty = property.FindPropertyRelative("geometryType"); - - float height = 0.0f; - height += (((((VectorPrimitiveType)sourceTypeProperty.enumValueIndex == VectorPrimitiveType.Line)) ? 5.0f : 4.0f) * EditorGUIUtility.singleLineHeight); + EditorGUILayout.PropertyField(property.FindPropertyRelative("snapToTerrain")); + EditorGUILayout.PropertyField(property.FindPropertyRelative("groupFeatures")); - return height; + if ((VectorPrimitiveType)primitiveType.enumValueIndex == VectorPrimitiveType.Line) + { + EditorGUILayout.PropertyField(property.FindPropertyRelative("lineWidth")); + } } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs index c73d7b001..cd884cee7 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs @@ -44,9 +44,6 @@ string CustomSourceMapId public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (ElevationSourceType)sourceTypeProperty.enumValueIndex; @@ -65,13 +62,11 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } isGUIContentSet = true; } - var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Data Source", tooltip = "Source tileset for Terrain." }); + var sourceTypeLabel = new GUIContent { text = "Data Source", tooltip = "Source tileset for Terrain." }; - sourceTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, sourceTypeProperty.enumValueIndex, sourceTypeContent); + sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent); sourceTypeValue = (ElevationSourceType)sourceTypeProperty.enumValueIndex; - position.y += lineHeight; - var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); @@ -81,12 +76,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var sourcePropertyValue = MapboxDefaultElevation.GetParameters(sourceTypeValue); layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; - EditorGUI.PropertyField(position, sourceOptionsProperty, _mapIdGui); + EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); GUI.enabled = true; break; case ElevationSourceType.Custom: layerSourceId.stringValue = CustomSourceMapId; - EditorGUI.PropertyField(position, sourceOptionsProperty, _mapIdGui); + EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); CustomSourceMapId = layerSourceId.stringValue; break; default: @@ -95,54 +90,32 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten //EditorGUI.PropertyField(position, property.FindPropertyRelative("sourceOptions"), true); - if (sourceTypeValue != ElevationSourceType.None) - { - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - } + //if (sourceTypeValue != ElevationSourceType.None) + //{ + // position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); + //} if (sourceTypeValue == ElevationSourceType.None) { GUI.enabled = false; } var elevationLayerType = property.FindPropertyRelative("elevationLayerType"); - EditorGUI.PropertyField(position, elevationLayerType, new GUIContent { text = elevationLayerType.displayName, tooltip = ((ElevationLayerType)elevationLayerType.enumValueIndex).Description() }); + EditorGUILayout.PropertyField(elevationLayerType, new GUIContent { text = elevationLayerType.displayName, tooltip = ((ElevationLayerType)elevationLayerType.enumValueIndex).Description() }); position.y += lineHeight; if (sourceTypeValue == ElevationSourceType.None) { GUI.enabled = true; } - EditorGUI.PropertyField(position, property.FindPropertyRelative("requiredOptions"), true); - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("requiredOptions")); - ShowPosition = EditorGUI.Foldout(position, ShowPosition, "Others"); + EditorGUILayout.PropertyField(property.FindPropertyRelative("requiredOptions"), true); + //position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("requiredOptions")); + ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others"); if (ShowPosition) { - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("modificationOptions"), true); - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("modificationOptions")); - EditorGUI.PropertyField(position, property.FindPropertyRelative("sideWallOptions"), true); - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sideWallOptions")); - EditorGUI.PropertyField(position, property.FindPropertyRelative("unityLayerOptions"), true); + EditorGUILayout.PropertyField(property.FindPropertyRelative("modificationOptions"), true); + EditorGUILayout.PropertyField(property.FindPropertyRelative("sideWallOptions"), true); + EditorGUILayout.PropertyField(property.FindPropertyRelative("unityLayerOptions"), true); } - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); - var sourceTypeValue = (ElevationSourceType)sourceTypeProperty.enumValueIndex; - - float height = ((sourceTypeValue == ElevationSourceType.None) ? 2.0f : 3.0f) * lineHeight; - - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("requiredOptions")); - if (ShowPosition) - { - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("modificationOptions")); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("unityLayerOptions")); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sideWallOptions")); - } - return height; } } - } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index a8097f9b2..338d23c15 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -9,22 +9,21 @@ public class GeometryExtrusionOptionsDrawer : PropertyDrawer { static float lineHeight = EditorGUIUtility.singleLineHeight; - GUIContent[] sourceTypeContent; + GUIContent[] extrusionTypeContent; bool isGUIContentSet = false; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); var extrusionTypeProperty = property.FindPropertyRelative("extrusionType"); - var displayNames = extrusionTypeProperty.enumDisplayNames; int count = extrusionTypeProperty.enumDisplayNames.Length; + if (!isGUIContentSet) { - sourceTypeContent = new GUIContent[count]; + extrusionTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { - sourceTypeContent[extIdx] = new GUIContent + extrusionTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((ExtrusionType)extIdx), @@ -33,12 +32,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten isGUIContentSet = true; } - var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Extrusion Type", tooltip = "Type of geometry extrusion" }); + var extrusionTypeLabel = new GUIContent + { + text = "Extrusion Type", + tooltip = "Type of geometry extrusion" + }; + extrusionTypeProperty.enumValueIndex = EditorGUILayout.Popup(extrusionTypeLabel, extrusionTypeProperty.enumValueIndex, extrusionTypeContent); - EditorGUI.indentLevel--; - extrusionTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, extrusionTypeProperty.enumValueIndex, sourceTypeContent); - EditorGUI.indentLevel++; var sourceTypeValue = (Unity.Map.ExtrusionType)extrusionTypeProperty.enumValueIndex; var minHeightProperty = property.FindPropertyRelative("minimumHeight"); @@ -52,83 +53,36 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten case Unity.Map.ExtrusionType.None: break; case Unity.Map.ExtrusionType.PropertyHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.MinHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.MaxHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.RangeHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), minHeightProperty); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), maxHeightProperty); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(property.FindPropertyRelative("propertyName")); + EditorGUILayout.PropertyField(minHeightProperty); + EditorGUILayout.PropertyField(maxHeightProperty); if (minHeightProperty.floatValue > maxHeightProperty.floatValue) { - //position.y += lineHeight; EditorGUILayout.HelpBox("Maximum Height less than Minimum Height!", MessageType.Error); } break; case Unity.Map.ExtrusionType.AbsoluteHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), maxHeightProperty, new GUIContent { text = "Height" }); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(maxHeightProperty, new GUIContent { text = "Height" }); break; default: break; } - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); + EditorGUILayout.PropertyField(property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); EditorGUI.indentLevel--; - - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var extrusionTypeProperty = property.FindPropertyRelative("extrusionType"); - var sourceTypeValue = (Unity.Map.ExtrusionType)extrusionTypeProperty.enumValueIndex; - - int rows = 1; - //if (showPosition) - { - switch (sourceTypeValue) - { - case Unity.Map.ExtrusionType.None: - rows += 1; - break; - case Unity.Map.ExtrusionType.PropertyHeight: - case Unity.Map.ExtrusionType.MinHeight: - case Unity.Map.ExtrusionType.MaxHeight: - rows += 3; - break; - case Unity.Map.ExtrusionType.RangeHeight: - rows += 5; - break; - case Unity.Map.ExtrusionType.AbsoluteHeight: - rows += 3; - break; - default: - rows += 2; - break; - } - } - return (float)rows * lineHeight; } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryMaterialOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryMaterialOptionsDrawer.cs index f2365c449..5500fd7c3 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryMaterialOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryMaterialOptionsDrawer.cs @@ -22,9 +22,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Texturing Type", tooltip = "Use image texture from the Imagery source as texture for roofs. " }); var texturingType = property.FindPropertyRelative("texturingType"); EditorGUI.indentLevel--; - EditorGUI.indentLevel--; + texturingType.enumValueIndex = EditorGUI.Popup(typePosition, texturingType.enumValueIndex, texturingType.enumDisplayNames); - EditorGUI.indentLevel++; + EditorGUI.indentLevel++; var matList = property.FindPropertyRelative("materials"); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs index 28b5678ad..881df8b75 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs @@ -33,9 +33,6 @@ string CustomSourceMapId public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; @@ -49,19 +46,18 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten sourceTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], - tooltip = ((ImagerySourceType)extIdx).Description(), + tooltip = EnumExtensions.Description((ImagerySourceType)extIdx), }; } isGUIContentSet = true; } - // Draw label. - var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Data Source", tooltip = "Source tileset for Imagery." }); + // Draw label. + var sourceTypeLabel = new GUIContent { text = "Data Source", tooltip = "Source tileset for Imagery." }; - sourceTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, sourceTypeProperty.enumValueIndex, sourceTypeContent); + sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent); sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; - position.y += lineHeight; var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); @@ -77,12 +73,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var sourcePropertyValue = MapboxDefaultImagery.GetParameters(sourceTypeValue); layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; - EditorGUI.PropertyField(position, sourceOptionsProperty,_mapIdGui); + EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); GUI.enabled = true; break; case ImagerySourceType.Custom: layerSourceId.stringValue = CustomSourceMapId; - EditorGUI.PropertyField(position, sourceOptionsProperty, new GUIContent{text = "Map Id / Style URL", tooltip = _mapIdGui.tooltip} ); + EditorGUILayout.PropertyField(sourceOptionsProperty, new GUIContent { text = "Map Id / Style URL", tooltip = _mapIdGui.tooltip }); CustomSourceMapId = layerSourceId.stringValue; break; case ImagerySourceType.None: @@ -92,29 +88,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } if (sourceTypeValue != ImagerySourceType.None) { - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - EditorGUI.PropertyField(position, property.FindPropertyRelative("rasterOptions")); - } - - EditorGUI.EndProperty(); - - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); - var sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; - - if (sourceTypeValue == ImagerySourceType.None) - { - return lineHeight; - } - else - { - float height = 0.0f; - height += (1.0f * lineHeight); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("rasterOptions")); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - return height; + EditorGUILayout.PropertyField(property.FindPropertyRelative("rasterOptions")); } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs index cdcffbd8e..06a339f90 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs @@ -15,61 +15,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { isActiveProperty = property.FindPropertyRelative("isEnabled"); - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent("Enable Coroutines")); - typePosition.x -= checkBoxOffset; - isActiveProperty.boolValue = EditorGUI.Toggle(typePosition, isActiveProperty.boolValue); + isActiveProperty.boolValue = EditorGUILayout.Toggle(new GUIContent("Enable Coroutines"), isActiveProperty.boolValue); if (isActiveProperty.boolValue == true) { EditorGUI.indentLevel++; - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("entityPerCoroutine"), true); + EditorGUILayout.PropertyField(property.FindPropertyRelative("entityPerCoroutine"), true); EditorGUI.indentLevel--; } - - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - float height = 0.0f; - if (isActiveProperty != null && isActiveProperty.boolValue == true) - { - height += (2.0f * EditorGUIUtility.singleLineHeight); - //height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("layerSource"), false); - } - else - { - height = EditorGUIUtility.singleLineHeight; - } - - return height; } } - - //[CustomPropertyDrawer(typeof(TypeVisualizerTuple))] - //public class TypeVisualizerBaseDrawer : PropertyDrawer - //{ - // static float lineHeight = EditorGUIUtility.singleLineHeight; - // bool showPosition = true; - // public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - // { - // EditorGUI.BeginProperty(position, label, property); - - // position.height = lineHeight; - - // EditorGUI.PropertyField(position, property.FindPropertyRelative("Stack")); - - // EditorGUI.EndProperty(); - // } - // public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - // { - // // Reserve space for the total visible properties. - // int rows = 2; - // //Debug.Log("Height - " + rows * lineHeight); - // return (float)rows * lineHeight; - // } - //} - -} \ No newline at end of file +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs index 55c1b6595..30c74417d 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs @@ -29,11 +29,10 @@ int SelectionIndex public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = _lineHeight; GUILayout.Space(-_lineHeight); var prefabItemArray = property.FindPropertyRelative("locationPrefabList"); var layersRect = GUILayoutUtility.GetRect(0, 500, Mathf.Max(prefabItemArray.arraySize + 1, 1) * _lineHeight, (prefabItemArray.arraySize + 1) * _lineHeight); + layerTreeView.Layers = prefabItemArray; layerTreeView.Reload(); layerTreeView.OnGUI(layersRect); @@ -124,7 +123,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten GUI.enabled = false; } - DrawLayerLocationPrefabProperties( layerProperty); + DrawLayerLocationPrefabProperties(layerProperty); if (!isLayerActive) { GUI.enabled = true; @@ -135,16 +134,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten GUILayout.Space(15); GUILayout.Label("Select a visualizer to see properties"); } - - EditorGUI.EndProperty(); } void DrawLayerLocationPrefabProperties(SerializedProperty layerProperty) { - EditorGUI.indentLevel++; EditorGUILayout.PropertyField(layerProperty); - EditorGUI.indentLevel--; } - } + } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapExtentOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapExtentOptionsDrawer.cs index bfbfbe498..af8ad507e 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapExtentOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapExtentOptionsDrawer.cs @@ -9,16 +9,11 @@ public class MapExtentOptionsDrawer : PropertyDrawer { static string extTypePropertyName = "extentType"; - static float lineHeight = EditorGUIUtility.singleLineHeight; + static float _lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] extentTypeContent; bool isGUIContentSet = false; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - - position.height = lineHeight; - - var kindProperty = property.FindPropertyRelative(extTypePropertyName); var displayNames = kindProperty.enumDisplayNames; int count = kindProperty.enumDisplayNames.Length; @@ -36,62 +31,36 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten isGUIContentSet = true; } // Draw label. - var kindPosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = "Options to determine the geographic extent of the world for which the map tiles will be requested.", }); - - kindProperty.enumValueIndex = EditorGUI.Popup(kindPosition, kindProperty.enumValueIndex, extentTypeContent); + 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.", + }; + kindProperty.enumValueIndex = EditorGUILayout.Popup(extentTypeLabel, kindProperty.enumValueIndex, extentTypeContent, GUILayout.Height(_lineHeight)); var kind = (MapExtentType)kindProperty.enumValueIndex; EditorGUI.indentLevel++; - var rect = new Rect(position.x, position.y + lineHeight, position.width, lineHeight); - + //var rect = new Rect(position.x, position.y + lineHeight, position.width, lineHeight); + GUILayout.Space(-_lineHeight); switch (kind) { case MapExtentType.CameraBounds: - EditorGUI.PropertyField(rect, property.FindPropertyRelative("cameraBoundsOptions"), new GUIContent { text = "CameraOptions-" }); + EditorGUILayout.PropertyField(property.FindPropertyRelative("cameraBoundsOptions"), new GUIContent { text = "CameraOptions-" }); break; case MapExtentType.RangeAroundCenter: - EditorGUI.PropertyField(rect, property.FindPropertyRelative("rangeAroundCenterOptions"), new GUIContent { text = "RangeAroundCenter" }); + EditorGUILayout.PropertyField(property.FindPropertyRelative("rangeAroundCenterOptions"), new GUIContent { text = "RangeAroundCenter" }); break; case MapExtentType.RangeAroundTransform: - EditorGUI.PropertyField(rect, property.FindPropertyRelative("rangeAroundTransformOptions"), new GUIContent { text = "RangeAroundTransform" }); + EditorGUILayout.PropertyField(property.FindPropertyRelative("rangeAroundTransformOptions"), new GUIContent { text = "RangeAroundTransform" }); break; default: break; } EditorGUI.indentLevel--; - - EditorGUI.EndProperty(); - - - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var kindProperty = property.FindPropertyRelative(extTypePropertyName); - - var kind = (MapExtentType)kindProperty.enumValueIndex; - - int rows = 1; - - switch (kind) - { - case MapExtentType.CameraBounds: - rows += 2; - break; - case MapExtentType.RangeAroundCenter: - rows += 4; - break; - case MapExtentType.RangeAroundTransform: - rows += 3; - break; - default: - break; - } - return (float)rows * EditorGUIUtility.singleLineHeight; } - } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs index f22f367cf..d18424752 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs @@ -7,26 +7,15 @@ [CustomPropertyDrawer(typeof(MapLocationOptions))] public class MapLocationOptionsDrawer : PropertyDrawer { - static float lineHeight = EditorGUIUtility.singleLineHeight; + static float _lineHeight = EditorGUIUtility.singleLineHeight; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - //EditorGUI.indentLevel++; - foreach (var item in property) - { - var subproperty = item as SerializedProperty; - EditorGUI.PropertyField(position, subproperty, true); - position.height = lineHeight; - position.y += lineHeight; - } - //EditorGUI.indentLevel--; - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - // Reserve space for the total visible properties. - return (2.0f * lineHeight); + EditorGUI.indentLevel++; + GUILayout.Space(-2f * _lineHeight); + EditorGUILayout.PropertyField(property.FindPropertyRelative("latitudeLongitude")); + EditorGUILayout.PropertyField(property.FindPropertyRelative("zoom"), GUILayout.Height(_lineHeight)); + EditorGUI.indentLevel--; } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapPlacementOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapPlacementOptionsDrawer.cs index 94e46b57b..70c2c9ffd 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapPlacementOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapPlacementOptionsDrawer.cs @@ -13,7 +13,6 @@ public class MapPlacementOptionsDrawer : PropertyDrawer bool isGUIContentSet = false; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); var placementType = property.FindPropertyRelative("placementType"); var snapMapToTerrain = property.FindPropertyRelative("snapMapToZero"); @@ -33,20 +32,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten isGUIContentSet = true; } - // Draw label. - var placementTypePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = "Placement of Map root.", }); - - placementType.enumValueIndex = EditorGUI.Popup(placementTypePosition, placementType.enumValueIndex, placementTypeContent); - - //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), placementType, new GUIContent { text = placementType.displayName, tooltip = EnumExtensions.Description((MapPlacementType)placementType.enumValueIndex) }); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), snapMapToTerrain, new GUIContent { text = snapMapToTerrain.displayName, tooltip = "If checked, map's root will be snapped to zero. " }); - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - // Reserve space for the total visible properties. - return 2.0f * lineHeight; + placementType.enumValueIndex = EditorGUILayout.Popup(new GUIContent { text = label.text, tooltip = "Placement of Map root.", }, placementType.enumValueIndex, placementTypeContent); + EditorGUILayout.PropertyField(snapMapToTerrain, new GUIContent { text = snapMapToTerrain.displayName, tooltip = "If checked, map's root will be snapped to zero. " }); } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapScalingOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapScalingOptionsDrawer.cs index 2a219fa9b..8639b3968 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapScalingOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapScalingOptionsDrawer.cs @@ -14,7 +14,6 @@ public class MapScalingOptionsDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); var scalingType = property.FindPropertyRelative("scalingType"); var displayNames = scalingType.enumDisplayNames; int count = scalingType.enumDisplayNames.Length; @@ -33,28 +32,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } // Draw label. - var scalingTypePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = "Scale of map in game units.", }); + var scalingTypeLabel = new GUIContent { text = label.text, tooltip = "Scale of map in game units.", }; - scalingType.enumValueIndex = EditorGUI.Popup(scalingTypePosition, scalingType.enumValueIndex, scalingTypeContent); + scalingType.enumValueIndex = EditorGUILayout.Popup(scalingTypeLabel, scalingType.enumValueIndex, scalingTypeContent); if ((MapScalingType)scalingType.enumValueIndex == MapScalingType.Custom) { position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("unityTileSize")); - } - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - // Reserve space for the total visible properties. - var scalingType = property.FindPropertyRelative("scalingType"); - if ((MapScalingType)scalingType.enumValueIndex == MapScalingType.Custom) - { - return 2.0f * lineHeight; - } - else - { - return 1.0f * lineHeight; + EditorGUILayout.PropertyField(property.FindPropertyRelative("unityTileSize")); } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs index c9bce3488..dd7cb8d81 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs @@ -5,13 +5,14 @@ namespace Mapbox.Editor using UnityEditor; using System; using System.Collections.Generic; + using Mapbox.VectorTile.ExtensionMethods; [CustomPropertyDrawer(typeof(PrefabItemOptions))] public class PrefabItemOptionsDrawer : PropertyDrawer { static float _lineHeight = EditorGUIUtility.singleLineHeight; - private int shiftLeftPixels = -16; + const string searchButtonContent = "Search"; private GUIContent prefabLocationsTitle = new GUIContent { text = "Prefab Locations", @@ -31,7 +32,7 @@ public class PrefabItemOptionsDrawer : PropertyDrawer tooltip = "Spawn at locations in the categories selected" }; - private GUIContent densitySlider = new GUIContent + private GUIContent densitySlider = new GUIContent { text = "Density", tooltip = "The number of prefabs to spawn per-tile; try a lower number if the map is cluttered" @@ -43,40 +44,59 @@ public class PrefabItemOptionsDrawer : PropertyDrawer tooltip = "Spawn at locations containing this name string" }; + GUIContent[] findByPropContent; + bool isGUIContentSet = false; + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - - position.y += 1.2f*_lineHeight; - + GUILayout.Space(-_lineHeight); var prefabItemCoreOptions = property.FindPropertyRelative("coreOptions"); GUILayout.Label(prefabItemCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties"); - GUILayout.Space(2.5f*EditorGUIUtility.singleLineHeight); //Prefab Game Object - position.y += _lineHeight; + GUILayout.Space(-_lineHeight); + EditorGUI.indentLevel++; var spawnPrefabOptions = property.FindPropertyRelative("spawnPrefabOptions"); - EditorGUI.PropertyField(new Rect(position.x, position.y + 2,position.width,2*_lineHeight),spawnPrefabOptions); + EditorGUILayout.PropertyField(spawnPrefabOptions); GUILayout.Space(1); + EditorGUI.indentLevel--; //Prefab Locations title GUILayout.Label(prefabLocationsTitle); //FindBy drop down - EditorGUI.indentLevel--; EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel(findByDropDown); + var findByProp = property.FindPropertyRelative("findByType"); - GUILayout.Space(shiftLeftPixels); - findByProp.enumValueIndex = EditorGUILayout.Popup(findByProp.enumValueIndex, findByProp.enumDisplayNames); + + 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++; + + findByProp.enumValueIndex = EditorGUILayout.Popup(findByDropDown, findByProp.enumValueIndex, findByPropContent); + EditorGUILayout.EndHorizontal(); - switch((LocationPrefabFindBy)findByProp.enumValueIndex) + switch ((LocationPrefabFindBy)findByProp.enumValueIndex) { case (LocationPrefabFindBy.MapboxCategory): ShowCategoryOptions(property); break; - case(LocationPrefabFindBy.AddressOrLatLon): + case (LocationPrefabFindBy.AddressOrLatLon): ShowAddressOrLatLonUI(property); break; case (LocationPrefabFindBy.POIName): @@ -85,28 +105,20 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten default: break; } - EditorGUI.indentLevel++; - - EditorGUI.EndProperty(); + EditorGUI.indentLevel--; } private void ShowCategoryOptions(SerializedProperty property) { //Category drop down - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel(categoriesDropDown); - var categoryProp = property.FindPropertyRelative("categories"); - GUILayout.Space(shiftLeftPixels); - categoryProp.intValue = (int)(LocationPrefabCategories)(EditorGUILayout.EnumFlagsField((LocationPrefabCategories)categoryProp.intValue)); - EditorGUILayout.EndHorizontal(); - + categoryProp.intValue = (int)(LocationPrefabCategories)(EditorGUILayout.EnumFlagsField(categoriesDropDown, (LocationPrefabCategories)categoryProp.intValue)); ShowDensitySlider(property); } private void ShowAddressOrLatLonUI(SerializedProperty property) { - EditorGUILayout.BeginVertical(); + //EditorGUILayout.BeginVertical(); var coordinateProperties = property.FindPropertyRelative("coordinates"); for (int i = 0; i < coordinateProperties.arraySize; i++) @@ -115,11 +127,20 @@ private void ShowAddressOrLatLonUI(SerializedProperty property) //get the element to draw var coordinate = coordinateProperties.GetArrayElementAtIndex(i); - //use the tagged property drawer for the coordinate layout - EditorGUILayout.PropertyField(coordinate); + //label for each location. + var coordinateLabel = String.Format("Location {0}", i); + + // draw coordinate string. + coordinate.stringValue = EditorGUILayout.TextField(coordinateLabel, coordinate.stringValue); + + // draw search button. + if (GUILayout.Button(new GUIContent(searchButtonContent), (GUIStyle)"minibuttonleft", GUILayout.MaxWidth(100))) + { + GeocodeAttributeSearchWindow.Open(coordinate); + } //include a remove button in the row - if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.MaxWidth(30))) { coordinateProperties.DeleteArrayElementAtIndex(i); } @@ -127,31 +148,24 @@ private void ShowAddressOrLatLonUI(SerializedProperty property) } EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel(" "); - GUILayout.Space(-5); - if(GUILayout.Button( "Add Location")) + 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 = ""; } EditorGUILayout.EndHorizontal(); - EditorGUILayout.EndVertical(); } private void ShowPOINames(SerializedProperty property) { //Name field - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel(nameField); - var categoryProp = property.FindPropertyRelative("nameString"); - GUILayout.Space(shiftLeftPixels); - categoryProp.stringValue = EditorGUILayout.TextField(categoryProp.stringValue); - EditorGUILayout.EndHorizontal(); + categoryProp.stringValue = EditorGUILayout.TextField(nameField, categoryProp.stringValue); ShowDensitySlider(property); } @@ -180,4 +194,4 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent return _lineHeight; } } -} \ No newline at end of file +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeAroundTransformTileProviderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeAroundTransformTileProviderOptionsDrawer.cs index e2344767b..76ce40176 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeAroundTransformTileProviderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeAroundTransformTileProviderOptionsDrawer.cs @@ -11,17 +11,13 @@ public class RangeAroundTransformTileProviderOptionsDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - //EditorGUI.indentLevel++; foreach (var item in property) { var subproperty = item as SerializedProperty; - EditorGUI.PropertyField(position, subproperty, true); + EditorGUILayout.PropertyField(subproperty, true); position.height = lineHeight; position.y += lineHeight; } - //EditorGUI.indentLevel--; - EditorGUI.EndProperty(); } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeTileProviderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeTileProviderOptionsDrawer.cs index dd7d7e5c0..f29868ad4 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeTileProviderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeTileProviderOptionsDrawer.cs @@ -10,17 +10,13 @@ public class RangeTileProviderOptionsDrawer : PropertyDrawer static float lineHeight = EditorGUIUtility.singleLineHeight; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - //EditorGUI.indentLevel++; foreach (var item in property) { var subproperty = item as SerializedProperty; - EditorGUI.PropertyField(position, subproperty, true); + EditorGUILayout.PropertyField(subproperty, true); position.height = lineHeight; position.y += lineHeight; } - //EditorGUI.indentLevel--; - EditorGUI.EndProperty(); } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs index ccb20cc36..db309a088 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs @@ -1,41 +1,37 @@ -namespace Mapbox.Unity.Map -{ - using System.Collections; - using System.Collections.Generic; - using UnityEngine; - using Mapbox.Unity.MeshGeneration.Modifiers; - using UnityEditor; - - [CustomPropertyDrawer(typeof(SpawnPrefabOptions))] - public class SpawnPrefabOptionsDrawer : PropertyDrawer - { - static float lineHeight = EditorGUIUtility.singleLineHeight; - - private GUIContent prefabContent = new GUIContent - { - text = "Prefab", - tooltip = "The prefab to be spawned" - }; - - private GUIContent scalePrefabContent = new GUIContent - { - text = "Scale down with world", - tooltip = "The prefab will scale with the map object" - }; - - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - EditorGUI.BeginProperty(position, label, property); - position.height = 2.5f * lineHeight; - EditorGUI.PropertyField(new Rect(position.x,position.y,position.width,lineHeight),property.FindPropertyRelative("prefab"), prefabContent); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width,lineHeight),property.FindPropertyRelative("scaleDownWithWorld"), scalePrefabContent); - EditorGUI.EndProperty(); - } - - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - return 0; - } - } -} +namespace Mapbox.Unity.Map +{ + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + using Mapbox.Unity.MeshGeneration.Modifiers; + using UnityEditor; + + [CustomPropertyDrawer(typeof(SpawnPrefabOptions))] + public class SpawnPrefabOptionsDrawer : PropertyDrawer + { + static float lineHeight = EditorGUIUtility.singleLineHeight; + + private GUIContent prefabContent = new GUIContent + { + text = "Prefab", + tooltip = "The prefab to be spawned" + }; + + private GUIContent scalePrefabContent = new GUIContent + { + text = "Scale down with world", + tooltip = "The prefab will scale with the map object" + }; + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField(property.FindPropertyRelative("prefab"), prefabContent); + EditorGUILayout.PropertyField(property.FindPropertyRelative("scaleDownWithWorld"), scalePrefabContent); + } + + //public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + //{ + // return 0; + //} + } +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/StyleOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/StyleOptionsDrawer.cs index 0e84f68a9..04cd7e80b 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/StyleOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/StyleOptionsDrawer.cs @@ -11,13 +11,8 @@ public class StyleOptionsDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - - position.height = lineHeight; - - EditorGUI.PropertyField(position, property.FindPropertyRelative("Id"), label); - - EditorGUI.EndProperty(); + GUILayout.Space(-lineHeight); + EditorGUILayout.PropertyField(property.FindPropertyRelative("Id"), label); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 588fb0ef5..23c8dc004 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -39,12 +39,12 @@ int SelectionIndex public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = _lineHeight; + //EditorGUI.BeginProperty(position, label, property); + //position.height = _lineHeight; GUILayout.Space(-_lineHeight); var sourceTypeProperty = property.FindPropertyRelative("_sourceType"); - var sourceTypeValue = (VectorSourceType) sourceTypeProperty.enumValueIndex; + var sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; if (sourceTypeValue != VectorSourceType.None) { @@ -79,7 +79,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } else { - selectedLayers = new int[1] {SelectionIndex}; + selectedLayers = new int[1] { SelectionIndex }; if (SelectionIndex > 0 && (SelectionIndex <= subLayerArray.arraySize - 1)) { layerTreeView.SetSelection(selectedLayers); @@ -90,7 +90,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten GUILayout.BeginHorizontal(); - if (GUILayout.Button(new GUIContent("Add Visualizer"), (GUIStyle) "minibuttonleft")) + if (GUILayout.Button(new GUIContent("Add Visualizer"), (GUIStyle)"minibuttonleft")) { subLayerArray.arraySize++; //subLayerArray.InsertArrayElementAtIndex(subLayerArray.arraySize); @@ -104,43 +104,43 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var subLayerCoreOptions = subLayer.FindPropertyRelative("coreOptions"); subLayerCoreOptions.FindPropertyRelative("isActive").boolValue = true; subLayerCoreOptions.FindPropertyRelative("layerName").stringValue = "building"; - subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex = (int) VectorPrimitiveType.Polygon; + subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex = (int)VectorPrimitiveType.Polygon; subLayerCoreOptions.FindPropertyRelative("snapToTerrain").boolValue = true; subLayerCoreOptions.FindPropertyRelative("groupFeatures").boolValue = false; subLayerCoreOptions.FindPropertyRelative("lineWidth").floatValue = 1.0f; var subLayerExtrusionOptions = subLayer.FindPropertyRelative("extrusionOptions"); - subLayerExtrusionOptions.FindPropertyRelative("extrusionType").enumValueIndex = (int) ExtrusionType.None; + subLayerExtrusionOptions.FindPropertyRelative("extrusionType").enumValueIndex = (int)ExtrusionType.None; subLayerExtrusionOptions.FindPropertyRelative("extrusionGeometryType").enumValueIndex = - (int) ExtrusionGeometryType.RoofAndSide; + (int)ExtrusionGeometryType.RoofAndSide; subLayerExtrusionOptions.FindPropertyRelative("propertyName").stringValue = "height"; subLayerExtrusionOptions.FindPropertyRelative("extrusionScaleFactor").floatValue = 1f; var subLayerFilterOptions = subLayer.FindPropertyRelative("filterOptions"); subLayerFilterOptions.FindPropertyRelative("filters").ClearArray(); subLayerFilterOptions.FindPropertyRelative("combinerType").enumValueIndex = - (int) LayerFilterCombinerOperationType.Any; + (int)LayerFilterCombinerOperationType.Any; var subLayerMaterialOptions = subLayer.FindPropertyRelative("materialOptions"); subLayerMaterialOptions.FindPropertyRelative("materials").ClearArray(); subLayerMaterialOptions.FindPropertyRelative("materials").arraySize = 2; subLayerMaterialOptions.FindPropertyRelative("atlasInfo").objectReferenceValue = null; subLayerMaterialOptions.FindPropertyRelative("colorPalette").objectReferenceValue = null; - subLayerMaterialOptions.FindPropertyRelative("texturingType").enumValueIndex = (int) UvMapType.Tiled; + subLayerMaterialOptions.FindPropertyRelative("texturingType").enumValueIndex = (int)UvMapType.Tiled; subLayer.FindPropertyRelative("buildingsWithUniqueIds").boolValue = false; - subLayer.FindPropertyRelative("moveFeaturePositionTo").enumValueIndex = (int) PositionTargetType.TileCenter; + subLayer.FindPropertyRelative("moveFeaturePositionTo").enumValueIndex = (int)PositionTargetType.TileCenter; subLayer.FindPropertyRelative("MeshModifiers").ClearArray(); subLayer.FindPropertyRelative("GoModifiers").ClearArray(); var subLayerColliderOptions = subLayer.FindPropertyRelative("colliderOptions"); - subLayerColliderOptions.FindPropertyRelative("colliderType").enumValueIndex = (int) ColliderType.None; + subLayerColliderOptions.FindPropertyRelative("colliderType").enumValueIndex = (int)ColliderType.None; - selectedLayers = new int[1] {subLayerArray.arraySize - 1}; + selectedLayers = new int[1] { subLayerArray.arraySize - 1 }; layerTreeView.SetSelection(selectedLayers); } - if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle) "minibuttonright")) + if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright")) { foreach (var index in selectedLayers.OrderByDescending(i => i)) { @@ -155,7 +155,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten GUILayout.Space(EditorGUIUtility.singleLineHeight); - if (selectedLayers.Count == 1 && subLayerArray.arraySize!=0) + if (selectedLayers.Count == 1 && subLayerArray.arraySize != 0) { //ensure that selectedLayers[0] isn't out of bounds if (selectedLayers[0] > subLayerArray.arraySize - 1) @@ -187,32 +187,33 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } } - EditorGUI.EndProperty(); + //EditorGUI.EndProperty(); } void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty) { - EditorGUI.indentLevel--; var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); - EditorGUI.indentLevel++; GUILayout.Label(subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties"); GUILayout.BeginVertical(); - + EditorGUI.indentLevel++; VectorPrimitiveType primitiveTypeProp = - (VectorPrimitiveType) subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex; + (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex; + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(subLayerCoreOptions); if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom) { + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("colliderOptions")); - + GUILayout.Space(-_lineHeight); + EditorGUI.indentLevel--; EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("extrusionOptions")); - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions")); + EditorGUI.indentLevel++; } - //EditorGUI.indentLevel--; + EditorGUI.indentLevel--; ShowOthers = EditorGUILayout.Foldout(ShowOthers, "Advanced"); EditorGUI.indentLevel++; if (ShowOthers) @@ -289,12 +290,12 @@ void DrawModifiers(SerializedProperty property, GUIContent label) EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false) as ScriptableObject; EditorGUILayout.EndVertical(); - if (GUILayout.Button(new GUIContent("+"), (GUIStyle) "minibuttonleft", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent("+"), (GUIStyle)"minibuttonleft", GUILayout.Width(30))) { ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac, ind); } - if (GUILayout.Button(new GUIContent("-"), (GUIStyle) "minibuttonright", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30))) { meshfac.DeleteArrayElementAtIndex(ind); } @@ -306,13 +307,13 @@ void DrawModifiers(SerializedProperty property, GUIContent label) EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(EditorGUI.indentLevel * 12); - if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle) "minibuttonleft")) + if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft")) { meshfac.arraySize++; meshfac.GetArrayElementAtIndex(meshfac.arraySize - 1).objectReferenceValue = null; } - if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle) "minibuttonright")) + if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright")) { ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac); } @@ -337,12 +338,12 @@ void DrawModifiers(SerializedProperty property, GUIContent label) false) as ScriptableObject; EditorGUILayout.EndVertical(); - if (GUILayout.Button(new GUIContent("+"), (GUIStyle) "minibuttonleft", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent("+"), (GUIStyle)"minibuttonleft", GUILayout.Width(30))) { ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac, ind); } - if (GUILayout.Button(new GUIContent("-"), (GUIStyle) "minibuttonright", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30))) { gofac.DeleteArrayElementAtIndex(ind); } @@ -354,13 +355,13 @@ void DrawModifiers(SerializedProperty property, GUIContent label) EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(EditorGUI.indentLevel * 12); - if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle) "minibuttonleft")) + if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft")) { gofac.arraySize++; gofac.GetArrayElementAtIndex(gofac.arraySize - 1).objectReferenceValue = null; } - if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle) "minibuttonright")) + if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright")) { ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac); } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs index e20612878..e7e88e6fc 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs @@ -33,7 +33,7 @@ protected override TreeViewItem BuildRoot() for (int i = 0; i < Layers.arraySize; i++) { var name = Layers.GetArrayElementAtIndex(i).FindPropertyRelative("coreOptions.sublayerName").stringValue; - items.Add(new TreeViewItem { id = index, depth = 0, displayName = name }); + items.Add(new TreeViewItem { id = index, depth = 1, displayName = name }); index++; } } @@ -61,16 +61,14 @@ protected override void RenameEnded(RenameEndedArgs args) layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = string.IsNullOrEmpty(args.newName.Trim()) ? args.originalName : args.newName; } - protected override void RowGUI (RowGUIArgs args) + protected override void RowGUI(RowGUIArgs args) { - EditorGUI.indentLevel--; Rect toggleRect = args.rowRect; toggleRect.width = kToggleWidth; var item = Layers.GetArrayElementAtIndex(args.item.id); item.FindPropertyRelative("coreOptions.isActive").boolValue = EditorGUI.Toggle(toggleRect, item.FindPropertyRelative("coreOptions.isActive").boolValue); args.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue; base.RowGUI(args); - EditorGUI.indentLevel++; } } }