Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
219 changes: 115 additions & 104 deletions sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ bool ShowFeatures
}
}


bool ShowPosition
{
get
Expand Down Expand Up @@ -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");
}

Expand All @@ -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");
}

Expand All @@ -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();

Expand All @@ -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"));
}

Expand All @@ -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++)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the rationale for the extIdx variable name that appears in all of these loops?

{
_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");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to rename the underlying classes along with the foldout title.

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

}
}
}
Loading