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
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,14 @@ private void DrawLayerName(SerializedProperty property, Rect position, List<stri
return;
}

if (!_isLayerNameGUIContentSet)

_layerTypeContent = new GUIContent[layerDisplayNames.Count];
for (int extIdx = 0; extIdx < layerDisplayNames.Count; extIdx++)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a more descriptive variable name than "extIdx"? "exitIndex?" (That's what I assume it's short for)

{
_layerTypeContent = new GUIContent[layerDisplayNames.Count];
for (int extIdx = 0; extIdx < layerDisplayNames.Count; extIdx++)
_layerTypeContent[extIdx] = new GUIContent
{
_layerTypeContent[extIdx] = new GUIContent
{
text = layerDisplayNames[extIdx],
};
}
_isLayerNameGUIContentSet = true;
text = layerDisplayNames[extIdx],
};
}

index = EditorGUILayout.Popup(layerNameLabel, index, _layerTypeContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,6 @@ int SelectionIndex
}
}

string CustomSourceMapId
{
get
{
return EditorPrefs.GetString(objectId + "VectorSubLayerProperties_customSourceMapId");
}
set
{
EditorPrefs.SetString(objectId + "VectorSubLayerProperties_customSourceMapId", value);
}
}

FeatureSubLayerTreeView layerTreeView = new FeatureSubLayerTreeView(new TreeViewState());
IList<int> selectedLayers = new List<int>();

Expand Down Expand Up @@ -149,9 +137,9 @@ public void DrawUI(SerializedProperty property)
isActiveProperty.boolValue = true;
break;
case VectorSourceType.Custom:
layerSourceId.stringValue = CustomSourceMapId;
if (_isInitialized)
{
string test = layerSourceId.stringValue;
LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
}
else
Expand All @@ -162,7 +150,6 @@ public void DrawUI(SerializedProperty property)
{
EditorGUILayout.HelpBox("Invalid Map Id / There might be a problem with the internet connection.", MessageType.Error);
}
CustomSourceMapId = layerSourceId.stringValue;
isActiveProperty.boolValue = true;
break;
case VectorSourceType.None:
Expand Down Expand Up @@ -503,9 +490,8 @@ private void LoadEditorTileJSON(SerializedProperty property, VectorSourceType so
{
if (sourceTypeValue != VectorSourceType.None && !string.IsNullOrEmpty(sourceString))
{
if (tileJSONResponse == null || string.IsNullOrEmpty(TilesetId) || sourceString != TilesetId)
if (tileJSONResponse == null || string.IsNullOrEmpty(sourceString) || sourceString != TilesetId)
{
TilesetId = sourceString;
//tileJSONData.ClearData();
try
{
Expand All @@ -531,12 +517,12 @@ private void LoadEditorTileJSON(SerializedProperty property, VectorSourceType so
{
tileJSONData.ProcessTileJSONData(tileJSONResponse);
}

}
else
{
tileJSONData.ClearData();
}
TilesetId = sourceString;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,41 +118,33 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position)
AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject;
tileJsonData = mapObject.VectorData.LayerProperty.tileJsonData;

DrawPropertyName(property, position, selectedLayerName);
}

private void DrawPropertyName(SerializedProperty property, Rect position, string selectedLayerName)
{
var descriptionString = "No description available";

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

dataUnavailable = false;
var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName];

if (_isInitialized == true)
else
{
if (!Enumerable.SequenceEqual(propertyNamesList, propertyDisplayNames))
dataUnavailable = false;
var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName];
if (_isInitialized == true)
{
index = 0;
propertyNamesList = propertyDisplayNames;
if (!Enumerable.SequenceEqual(propertyNamesList, propertyDisplayNames))
{
index = 0;
}
}
else
{
DrawPropertyName(property, position, propertyDisplayNames, selectedLayerName);
_isInitialized = true;
}
}
else
{
_isInitialized = true;
DrawPropertyName(property, position, propertyDisplayNames, selectedLayerName);
}
}

private void DrawPropertyName(SerializedProperty property, Rect position, List<string> propertyDisplayNames, string selectedLayerName)
{
propertyNamesList = propertyDisplayNames;

if (!_isLayerNameGUIContentSet)
{
propertyNamesList = propertyDisplayNames;
_propertyNameContent = new GUIContent[propertyNamesList.Count];
for (int extIdx = 0; extIdx < propertyNamesList.Count; extIdx++)
{
Expand All @@ -163,16 +155,15 @@ private void DrawPropertyName(SerializedProperty property, Rect position, List<s
tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString]
};
}
_isLayerNameGUIContentSet = true;
}

var propertyNameLabel = new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" };
index = EditorGUILayout.Popup(propertyNameLabel, index, _propertyNameContent);
var parsedString = propertyNamesList[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString];
var propertyNameLabel = new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" };
index = EditorGUILayout.Popup(propertyNameLabel, index, _propertyNameContent);
var parsedString = propertyNamesList[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim();
descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString];
property.FindPropertyRelative("propertyName").stringValue = parsedString;
}

descriptionString = string.IsNullOrEmpty(descriptionString) ? "No description available" : descriptionString;
property.FindPropertyRelative("propertyName").stringValue = parsedString;

var propertyDescriptionPrefixLabel = new GUIContent { text = "Property Description", tooltip = "Factual information about the selected property" };
EditorGUILayout.LabelField(propertyDescriptionPrefixLabel, new GUIContent(descriptionString), (GUIStyle)"wordWrappedLabel");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,34 +185,8 @@ private void DrawWarningMessage()
dataUnavailable = true;
GUIStyle labelStyle = new GUIStyle(EditorStyles.popup);
labelStyle.fontStyle = FontStyle.Bold;
EditorGUILayout.LabelField(new GUIContent(), new GUIContent("Check MapId / Internet."), labelStyle, new GUILayoutOption[]{ GUILayout.MaxWidth(160) });//(GUIStyle)"minipopUp");
EditorGUILayout.LabelField(new GUIContent(), new GUIContent("Check MapId / Internet."), labelStyle, new GUILayoutOption[]{ GUILayout.MaxWidth(155) });//(GUIStyle)"minipopUp");
return;
}
}


//[CustomPropertyDrawer(typeof(TypeVisualizerTuple))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for removing all this 👌

//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;
// }
//}

}
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,19 @@ protected virtual void QueryHeight(VectorFeatureUnity feature, MeshData md, Unit
case ExtrusionType.MaxHeight:
if (feature.Properties.ContainsKey(_options.propertyName))
{
maxHeight = Convert.ToSingle(feature.Properties[_options.propertyName]);
try
{
maxHeight = Convert.ToSingle(feature.Properties[_options.propertyName]);
}
catch (Exception ex)
{
Debug.LogError("Property: '" + _options.propertyName + "' must contain a numerical value for extrusion.");
return;
}




if (feature.Properties.ContainsKey("min_height"))
{
minHeight = Convert.ToSingle(feature.Properties["min_height"]);
Expand All @@ -248,7 +260,18 @@ protected virtual void QueryHeight(VectorFeatureUnity feature, MeshData md, Unit
_options.minimumHeight = _options.maximumHeight;
_options.maximumHeight = temp;
}
var featureHeight = Convert.ToSingle(feature.Properties[_options.propertyName]);

float featureHeight;
try
{
featureHeight = Convert.ToSingle(feature.Properties[_options.propertyName]);
}
catch (Exception ex)
{
Debug.LogError("Property: '" + _options.propertyName + "' must contain a numerical value for extrusion.");
return;
}

maxHeight = Math.Min(Math.Max(_options.minimumHeight, featureHeight), _options.maximumHeight);
if (feature.Properties.ContainsKey("min_height"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private void GenerateRoofMesh(MeshData md, float minHeight, float maxHeight)
}
}

private void QueryHeight(VectorFeatureUnity feature, MeshData md, UnityTile tile, out float maxHeight, out float minHeight)
protected virtual void QueryHeight(VectorFeatureUnity feature, MeshData md, UnityTile tile, out float maxHeight, out float minHeight)
{
minHeight = 0.0f;
maxHeight = 0.0f;
Expand All @@ -391,11 +391,20 @@ private void QueryHeight(VectorFeatureUnity feature, MeshData md, UnityTile tile
case ExtrusionType.MaxHeight:
if (feature.Properties.ContainsKey(_options.propertyName))
{
maxHeight = Convert.ToSingle(feature.Properties[_options.propertyName]);
try
{
maxHeight = Convert.ToSingle(feature.Properties[_options.propertyName]);
}
catch (Exception ex)
{
Debug.LogError("Property: '" + _options.propertyName + "' must contain a numerical value for extrusion.");
return;
}

if (feature.Properties.ContainsKey("min_height"))
{
minHeight = Convert.ToSingle(feature.Properties["min_height"]);
//hf -= minHeight;
//maxHeight -= minHeight;
}
}
break;
Expand All @@ -409,13 +418,23 @@ private void QueryHeight(VectorFeatureUnity feature, MeshData md, UnityTile tile
_options.minimumHeight = _options.maximumHeight;
_options.maximumHeight = temp;
}
var featureHeight = Convert.ToSingle(feature.Properties[_options.propertyName]);

float featureHeight;
try
{
featureHeight = Convert.ToSingle(feature.Properties[_options.propertyName]);
}
catch (Exception ex)
{
Debug.LogError("Property: '" + _options.propertyName + "' must contain a numerical value for extrusion.");
return;
}

maxHeight = Math.Min(Math.Max(_options.minimumHeight, featureHeight), _options.maximumHeight);
if (feature.Properties.ContainsKey("min_height"))
{
var featureMinHeight = Convert.ToSingle(feature.Properties["min_height"]);
minHeight = Math.Min(featureMinHeight, _options.maximumHeight);
//maxHeight -= minHeight;
}
}
break;
Expand Down