diff --git a/Assets/Editor/EditorBase.cs b/Assets/Editor/EditorBase.cs
deleted file mode 100644
index 0af0295a..00000000
--- a/Assets/Editor/EditorBase.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-
-///
-/// Base class for editor, each editor has a unique guid used
-/// for saving custom preferences in the Unity editor prefs.
-///
-public class EditorBase
-{
- protected Guid guid;
-
- public EditorBase()
- {
- guid = Guid.NewGuid();
- }
-
- public Guid GUID
- {
- get { return guid; }
- }
-}
diff --git a/Assets/Editor/EditorConfig.cs b/Assets/Editor/EditorConfig.cs
deleted file mode 100644
index b3b62f00..00000000
--- a/Assets/Editor/EditorConfig.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using UnityEditor;
-using UnityEngine;
-
-///
-/// Styling configuration for the editor.
-///
-public class EditorConfig
-{
- public static Color AddButtonColor = new Color(0.8f, 0.8f, 0.8f);
-
- public static Color DownloadButtonEnabledColor = new Color(0.35f, 0.80f, 0.30f);
-
- public static Color DownloadButtonDisabledColor = new Color(0.45f, 0.45f, 0.45f);
-
- public static Color RemoveButtonColor = new Color(0.5f, 0.5f, 0.5f);
-
- public static GUILayoutOption SmallButtonWidth = GUILayout.Width(50.0f);
-
- public static GUIContent AddButtonContent = new GUIContent("+", "Add");
-
- public static GUIContent RemoveButtonContent = new GUIContent("-", "Remove");
-
- public static Color DefaultColor;
-
- ///
- /// Globally sets the color of the GUI, saves the current color.
- ///
- /// Color.
- public static void SetColor(Color color)
- {
- DefaultColor = GUI.color;
- GUI.color = color;
- }
-
- ///
- /// Globally resets the color of the GUI to its previous state.
- ///
- public static void ResetColor()
- {
- GUI.color = DefaultColor;
- }
-}
-
diff --git a/Assets/Editor/FeatureStyleEditor.cs b/Assets/Editor/FeatureStyleEditor.cs
deleted file mode 100644
index 4ddbdb2a..00000000
--- a/Assets/Editor/FeatureStyleEditor.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using UnityEditor;
-using UnityEngine;
-using System;
-using Mapzen;
-using Mapzen.Unity;
-
-[CustomEditor(typeof(FeatureStyle))]
-public class FeatureStyleEditor : Editor
-{
- private FeatureStyle featureStyle;
- private StyleEditor styleEditor;
-
- void OnEnable()
- {
- featureStyle = (FeatureStyle)target;
- styleEditor = featureStyle.Editor as StyleEditor;
-
- if (styleEditor == null)
- {
- styleEditor = new StyleEditor(featureStyle);
- featureStyle.Editor = styleEditor;
- }
- }
-
- public override void OnInspectorGUI()
- {
- styleEditor.OnInspectorGUI();
-
- EditorUtility.SetDirty(featureStyle);
- }
-}
\ No newline at end of file
diff --git a/Assets/Editor/FilterStyleEditor.cs b/Assets/Editor/FilterStyleEditor.cs
deleted file mode 100644
index d6b6704c..00000000
--- a/Assets/Editor/FilterStyleEditor.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using Mapzen;
-using Mapzen.Unity;
-using Mapzen.VectorData.Filters;
-using UnityEditor;
-using UnityEngine;
-
-[Serializable]
-public class FilterStyleEditor : EditorBase
-{
- [SerializeField]
- private int selectedLayer;
-
- [SerializeField]
- private FeatureStyle.Matcher.Type selectedMatcherType;
-
- [SerializeField]
- private List layerStyleEditors;
-
- [SerializeField]
- private MatcherEditor matcherEditor;
-
- [SerializeField]
- private FeatureStyle.FilterStyle filterStyle;
-
- public FeatureStyle.FilterStyle FilterStyle
- {
- get { return filterStyle; }
- }
-
- public FilterStyleEditor(FeatureStyle.FilterStyle filterStyle)
- : base()
- {
- this.filterStyle = filterStyle;
- this.layerStyleEditors = new List();
-
- foreach (var layerStyle in filterStyle.LayerStyles)
- {
- layerStyleEditors.Add(new LayerStyleEditor(layerStyle));
- }
-
- if (filterStyle.Matcher != null)
- {
- selectedMatcherType = filterStyle.Matcher.MatcherType;
- this.matcherEditor = new MatcherEditor(filterStyle.Matcher);
- }
- }
-
- private void AddLayerStyleLayout(FeatureStyle.FilterStyle filterStyle, string name)
- {
- EditorConfig.SetColor(EditorConfig.AddButtonColor);
- if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth))
- {
- // Layers within a filter are identifier by their layer name
- var queryLayer = filterStyle.LayerStyles.Where(layerStyle => name == layerStyle.LayerName);
-
- if (name.Length == 0)
- {
- Debug.LogError("Layer name can't be empty");
- }
- else if (queryLayer.Count() > 0)
- {
- Debug.LogError("A layer with name " + name + " already exists");
- }
- else
- {
- var layerStyle = new FeatureStyle.LayerStyle(name);
-
- // Default configuration for the layer
- layerStyle.PolygonBuilderOptions = PolygonBuilderEditor.DefaultOptions();
- layerStyle.PolylineBuilderOptions = PolylineBuilderEditor.DefaultOptions();
- layerStyle.Material = new Material(Shader.Find("Diffuse"));
-
- filterStyle.LayerStyles.Add(layerStyle);
-
- // Create the associated layer editor
- layerStyleEditors.Add(new LayerStyleEditor(layerStyle));
- }
- }
- EditorConfig.ResetColor();
- }
-
- public void OnInspectorGUI(List layers)
- {
- EditorGUILayout.BeginHorizontal();
- {
- selectedLayer = EditorGUILayout.Popup("Layer:", selectedLayer, layers.ToArray());
- if (layers.Count > 0) {
- AddLayerStyleLayout(filterStyle, layers[selectedLayer]);
- }
- }
- EditorGUILayout.EndHorizontal();
-
- EditorGUI.indentLevel++;
-
- for (int i = layerStyleEditors.Count - 1; i >= 0; i--)
- {
- var editor = layerStyleEditors[i];
- var layerStyling = editor.LayerStyle;
-
- var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), layerStyling.LayerName);
-
- if (state.show)
- {
- editor.OnInspectorGUI();
- }
-
- if (state.markedForDeletion)
- {
- // Remove the layer from the filter styles
- filterStyle.LayerStyles.Remove(layerStyling);
-
- // Remove the associated layer editor
- layerStyleEditors.RemoveAt(i);
- }
- }
-
- EditorGUI.indentLevel--;
-
- var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast();
- var matcherTypeStringList = matcherTypeList.Select(type => type.ToString());
- var oldType = selectedMatcherType;
-
- selectedMatcherType = (FeatureStyle.Matcher.Type)EditorGUILayout.Popup("Matcher:",
- (int)selectedMatcherType, matcherTypeStringList.ToArray());
-
- if (selectedMatcherType != oldType)
- {
- matcherEditor = new MatcherEditor(new FeatureStyle.Matcher(selectedMatcherType));
- }
- else
- {
- if (selectedMatcherType == FeatureStyle.Matcher.Type.None)
- {
- matcherEditor = null;
- }
- }
-
- if (matcherEditor != null)
- {
- matcherEditor.OnInspectorGUI();
-
- filterStyle.Matcher = matcherEditor.Matcher;
- }
- }
-}
diff --git a/Assets/Editor/FoldoutEditor.cs b/Assets/Editor/FoldoutEditor.cs
deleted file mode 100644
index e20c1436..00000000
--- a/Assets/Editor/FoldoutEditor.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using UnityEditor;
-using UnityEngine;
-
-public class FoldoutEditor
-{
- public class State
- {
- // Whether the foldout panel is shown
- public bool show;
- // Whether the foldout panel is marked for deletion
- public bool markedForDeletion;
-
- public State()
- {
- this.markedForDeletion = false;
- this.show = false;
- }
- }
-
- public static bool LoadPreferences(string editorIdentifier)
- {
- return EditorPrefs.GetBool(editorIdentifier + ".show");
- }
-
- public static void SavePrefences(string editorIdentifier, bool show)
- {
- EditorPrefs.SetBool(editorIdentifier + ".show", show);
- }
-
- public static State OnInspectorGUI(string editorIdentifier, string foldoutName)
- {
- var state = new State();
-
- state.show = LoadPreferences(editorIdentifier);
-
- EditorGUILayout.BeginHorizontal();
- {
- state.show = EditorGUILayout.Foldout(state.show, foldoutName);
-
- EditorConfig.SetColor(EditorConfig.RemoveButtonColor);
- if (GUILayout.Button(EditorConfig.RemoveButtonContent, EditorConfig.SmallButtonWidth))
- {
- state.markedForDeletion = true;
- }
- EditorConfig.ResetColor();
- }
- EditorGUILayout.EndHorizontal();
-
- SavePrefences(editorIdentifier, state.show);
-
- return state;
- }
-}
diff --git a/Assets/Editor/LayerStyleEditor.cs b/Assets/Editor/LayerStyleEditor.cs
deleted file mode 100644
index da8b0387..00000000
--- a/Assets/Editor/LayerStyleEditor.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using Mapzen;
-using Mapzen.Unity;
-using UnityEditor;
-using UnityEngine;
-
-[SerializeField]
-public class LayerStyleEditor : EditorBase
-{
- [SerializeField]
- private PolygonBuilderEditor polygonBuilderEditor;
-
- [SerializeField]
- private PolylineBuilderEditor polylineBuilderEditor;
-
- [SerializeField]
- private FeatureStyle.LayerStyle layerStyle;
-
- public FeatureStyle.LayerStyle LayerStyle
- {
- get { return layerStyle; }
- }
-
- public LayerStyleEditor(FeatureStyle.LayerStyle layerStyle)
- : base()
- {
- this.polygonBuilderEditor = new PolygonBuilderEditor();
- this.polylineBuilderEditor = new PolylineBuilderEditor();
- this.layerStyle = layerStyle;
- }
-
- public void OnInspectorGUI()
- {
- EditorGUI.indentLevel++;
-
- layerStyle.PolygonBuilderOptions = polygonBuilderEditor.OnInspectorGUI(layerStyle.PolygonBuilderOptions);
- layerStyle.PolylineBuilderOptions = polylineBuilderEditor.OnInspectorGUI(layerStyle.PolylineBuilderOptions);
-
- EditorGUI.indentLevel--;
-
- layerStyle.Material = EditorGUILayout.ObjectField("Material:", layerStyle.Material, typeof(Material)) as Material;
- }
-}
diff --git a/Assets/Editor/MapzenMapEditor.cs b/Assets/Editor/MapzenMapEditor.cs
deleted file mode 100644
index 55fedeb2..00000000
--- a/Assets/Editor/MapzenMapEditor.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-using UnityEngine;
-using System.Linq;
-using System.Collections.Generic;
-using Mapzen;
-using UnityEditor;
-
-[CustomEditor(typeof(MapzenMap))]
-public class MapzenMapEditor : Editor
-{
- private MapzenMap mapzenMap;
- private bool showTileDataFoldout = false;
- private bool showRegionScaleRatioFoldout = false;
-
- void OnEnable()
- {
- this.mapzenMap = (MapzenMap)target;
- }
-
- public override void OnInspectorGUI()
- {
- LoadPreferences();
-
- TileDataFoldout();
-
- RegionScaleRatioFoldout();
-
- base.OnInspectorGUI();
-
- bool valid = IsValid();
-
- EditorConfig.SetColor(valid ?
- EditorConfig.DownloadButtonEnabledColor :
- EditorConfig.DownloadButtonDisabledColor);
-
- if (GUILayout.Button("Download"))
- {
- if (valid)
- {
- LogWarnings();
-
- mapzenMap.DownloadTiles();
- }
- else
- {
- LogErrors();
- }
- }
-
- EditorConfig.ResetColor();
-
- SavePreferences();
- }
-
- private void SceneGroupToggle(MapzenMap mapzenMap, SceneGroup.Type type)
- {
- bool isSet = SceneGroup.Test(type, mapzenMap.GroupOptions);
- isSet = EditorGUILayout.Toggle(type.ToString(), isSet);
-
- mapzenMap.GroupOptions = isSet ?
- mapzenMap.GroupOptions | type :
- mapzenMap.GroupOptions & ~type;
- }
-
- private void TileDataFoldout()
- {
- showTileDataFoldout = EditorGUILayout.Foldout(showTileDataFoldout, "Tile data");
- if (!showTileDataFoldout)
- {
- return;
- }
-
- GUILayout.Label("Group by:");
-
- EditorGUI.indentLevel++;
-
- EditorGUILayout.BeginHorizontal();
- SceneGroupToggle(mapzenMap, SceneGroup.Type.Feature);
- SceneGroupToggle(mapzenMap, SceneGroup.Type.Filter);
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginHorizontal();
- SceneGroupToggle(mapzenMap, SceneGroup.Type.Layer);
- SceneGroupToggle(mapzenMap, SceneGroup.Type.Tile);
- EditorGUILayout.EndHorizontal();
-
- EditorGUI.indentLevel--;
- }
-
- private void UnitScaleToggle(MapzenMap mapzenMap, RegionScaleUnits.Units unit)
- {
- bool isSet = RegionScaleUnits.Test(unit, mapzenMap.RegionScaleUnit);
- isSet = EditorGUILayout.Toggle(unit.ToString(), isSet);
-
- mapzenMap.RegionScaleUnit = isSet ? unit : mapzenMap.RegionScaleUnit;
- }
-
- private void RegionScaleRatioFoldout()
- {
- showRegionScaleRatioFoldout = EditorGUILayout.Foldout(showRegionScaleRatioFoldout, "Region Scale Ratio");
- if (!showRegionScaleRatioFoldout)
- {
- return;
- }
-
- mapzenMap.RegionScaleRatio = EditorGUILayout.FloatField("Scale: ", mapzenMap.RegionScaleRatio);
- GUILayout.Label("Choose world scale units: ");
- EditorGUI.indentLevel++;
-
- EditorGUILayout.BeginHorizontal();
- UnitScaleToggle(mapzenMap, RegionScaleUnits.Units.Meters);
- UnitScaleToggle(mapzenMap, RegionScaleUnits.Units.KiloMeters);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.BeginHorizontal();
- UnitScaleToggle(mapzenMap, RegionScaleUnits.Units.Miles);
- UnitScaleToggle(mapzenMap, RegionScaleUnits.Units.Feet);
- EditorGUILayout.EndHorizontal();
-
- EditorGUI.indentLevel--;
- }
-
- private void LoadPreferences()
- {
- string key = typeof(MapzenMapEditor).Name;
- showTileDataFoldout = EditorPrefs.GetBool(key + ".showTileDataFoldout");
- showRegionScaleRatioFoldout = EditorPrefs.GetBool(key + ".showRegionScaleRatioFoldout");
- }
-
- private void SavePreferences()
- {
- string key = typeof(MapzenMapEditor).Name;
- EditorPrefs.SetBool(key + ".showTileDataFoldout", showTileDataFoldout);
- EditorPrefs.SetBool(key + ".showRegionScaleRatioFoldout", showRegionScaleRatioFoldout);
- }
-
- private bool IsValid()
- {
- return mapzenMap.RegionName.Length > 0 && mapzenMap.FeatureStyling.Count > 0;
- }
-
- private void LogWarnings()
- {
- foreach (var style in mapzenMap.FeatureStyling)
- {
- if (style == null)
- {
- Debug.LogWarning("'Null' style provided in feature styling collection");
- continue;
- }
-
- if (style.FilterStyles.Count == 0)
- {
- Debug.LogWarning("The style " + style.name + " has no filter");
- }
-
- foreach (var filterStyle in style.FilterStyles)
- {
- if (filterStyle.GetFilter().CollectionNameSet.Count == 0)
- {
- Debug.LogWarning("The style " + style.name + " has a filter selecting no layer");
- }
- }
- }
- }
-
- private void LogErrors()
- {
- if (mapzenMap.RegionName.Length == 0)
- {
- Debug.LogError("Make sure to give a region name");
- }
-
- if (mapzenMap.FeatureStyling.Count == 0)
- {
- Debug.LogError("Make sure to create at least one style");
- }
- }
-}
diff --git a/Assets/Editor/MatcherEditor.cs b/Assets/Editor/MatcherEditor.cs
deleted file mode 100644
index 7cb388f1..00000000
--- a/Assets/Editor/MatcherEditor.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using Mapzen;
-using Mapzen.Unity;
-using Mapzen.VectorData.Filters;
-using UnityEditor;
-using UnityEngine;
-
-[Serializable]
-public class MatcherEditor : EditorBase
-{
- [SerializeField]
- private FeatureStyle.Matcher.Type selectedMatcherType;
-
- [SerializeField]
- private FeatureStyle.Matcher matcher;
-
- [SerializeField]
- private List matcherEditors;
-
- public FeatureStyle.Matcher Matcher
- {
- get { return matcher; }
- }
-
- public MatcherEditor(FeatureStyle.Matcher matcher)
- : base()
- {
- this.matcher = matcher;
- this.matcherEditors = new List();
-
- foreach (var matcherChild in matcher.Matchers)
- {
- this.matcherEditors.Add(new MatcherEditor(matcherChild));
- }
- }
-
- private MatcherEditor AddMatcherLayout()
- {
- MatcherEditor editor = null;
-
- EditorGUILayout.BeginHorizontal();
- {
- var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast();
- var matcherTypeStringList = matcherTypeList.Select(type => type.ToString());
-
- selectedMatcherType = (FeatureStyle.Matcher.Type)EditorGUILayout.Popup("Matcher:",
- (int)selectedMatcherType, matcherTypeStringList.ToArray());
-
- EditorConfig.SetColor(EditorConfig.AddButtonColor);
- if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth)
- && selectedMatcherType != FeatureStyle.Matcher.Type.None)
- {
- var matcherType = (FeatureStyle.Matcher.Type)selectedMatcherType;
- var newMatcher = new FeatureStyle.Matcher(matcherType);
-
- editor = new MatcherEditor(newMatcher);
- matcher.Matchers.Add(newMatcher);
- }
- EditorConfig.ResetColor();
- }
- EditorGUILayout.EndHorizontal();
-
- return editor;
- }
-
- public void OnInspectorGUI()
- {
- EditorGUI.indentLevel++;
-
- if (matcher.IsCompound())
- {
- var editor = AddMatcherLayout();
- if (editor != null)
- {
- matcherEditors.Add(editor);
- }
- }
- else
- {
- switch (matcher.MatcherType)
- {
- case FeatureStyle.Matcher.Type.Property:
- matcher.HasProperty = EditorGUILayout.TextField("Has property:", matcher.HasProperty);
- break;
-
- case FeatureStyle.Matcher.Type.PropertyRange:
- matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
- EditorGUILayout.BeginHorizontal();
- matcher.MinRange = EditorGUILayout.FloatField("min:", matcher.MinRange);
- matcher.MinRangeEnabled = EditorGUILayout.Toggle(matcher.MinRangeEnabled);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.BeginHorizontal();
- matcher.MaxRange = EditorGUILayout.FloatField("max:", matcher.MaxRange);
- matcher.MaxRangeEnabled = EditorGUILayout.Toggle(matcher.MaxRangeEnabled);
- EditorGUILayout.EndHorizontal();
- break;
-
- case FeatureStyle.Matcher.Type.PropertyValue:
- matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
- matcher.PropertyValue = EditorGUILayout.TextField("Property value:", matcher.PropertyValue);
- break;
-
- case FeatureStyle.Matcher.Type.PropertyRegex:
- matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
- matcher.RegexPattern = EditorGUILayout.TextField("Regex:", matcher.RegexPattern);
- break;
- }
- }
-
- for (int i = matcherEditors.Count - 1; i >= 0; i--)
- {
- var editor = matcherEditors[i];
-
- var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), editor.Matcher.MatcherType.ToString());
-
- if (state.show)
- {
- editor.OnInspectorGUI();
- }
-
- if (state.markedForDeletion)
- {
- matcher.Matchers.Remove(editor.Matcher);
- matcherEditors.RemoveAt(i);
- }
- }
-
- EditorGUI.indentLevel--;
- }
-}
-
-
diff --git a/Assets/Editor/PolygonBuilderEditor.cs b/Assets/Editor/PolygonBuilderEditor.cs
deleted file mode 100644
index 52811c47..00000000
--- a/Assets/Editor/PolygonBuilderEditor.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using UnityEngine;
-using UnityEditor;
-using Mapzen;
-using System.Linq;
-using Mapzen.Unity;
-using System;
-
-[Serializable]
-public class PolygonBuilderEditor : EditorBase
-{
- [SerializeField]
- private bool show;
-
- public PolygonBuilderEditor()
- : base()
- {
- this.show = false;
- }
-
- public static PolygonBuilder.Options DefaultOptions()
- {
- var defaultOptions = new PolygonBuilder.Options();
-
- defaultOptions.Extrusion = PolygonBuilder.ExtrusionType.TopAndSides;
- defaultOptions.UVMode = UVMode.Tile;
- defaultOptions.Enabled = true;
- defaultOptions.MaxHeight = 0.0f;
-
- return defaultOptions;
- }
-
- private void LoadPreferences()
- {
- show = EditorPrefs.GetBool(guid + ".show");
- }
-
- private void SavePreferences()
- {
- EditorPrefs.SetBool(guid + ".show", show);
- }
-
- public PolygonBuilder.Options OnInspectorGUI(PolygonBuilder.Options options)
- {
- LoadPreferences();
-
- show = EditorGUILayout.Foldout(show, "Polygon builder options");
-
- if (!show)
- {
- SavePreferences();
- return options;
- }
-
- options.MaxHeight = EditorGUILayout.FloatField("Max Height: ", options.MaxHeight);
- options.Extrusion = (PolygonBuilder.ExtrusionType)EditorGUILayout.EnumPopup("Extrusion type: ", options.Extrusion);
- options.UVMode = (UVMode)EditorGUILayout.EnumPopup("UV Mode:", options.UVMode);
- options.Enabled = EditorGUILayout.Toggle("Enabled: ", options.Enabled);
-
- SavePreferences();
-
- return options;
- }
-}
diff --git a/Assets/Editor/PolylineBuilderEditor.cs b/Assets/Editor/PolylineBuilderEditor.cs
deleted file mode 100644
index 16340cb9..00000000
--- a/Assets/Editor/PolylineBuilderEditor.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using UnityEngine;
-using UnityEditor;
-using Mapzen;
-using Mapzen.Unity;
-using System.Linq;
-using System;
-
-[Serializable]
-public class PolylineBuilderEditor : EditorBase
-{
- [SerializeField]
- private bool show;
-
- public PolylineBuilderEditor()
- : base()
- {
- this.show = false;
- }
-
- public static PolylineBuilder.Options DefaultOptions()
- {
- var defaultOptions = new PolylineBuilder.Options();
-
- defaultOptions.Extrusion = PolygonBuilder.ExtrusionType.TopAndSides;
- defaultOptions.Enabled = true;
- defaultOptions.MaxHeight = 3.0f;
- defaultOptions.MiterLimit = 3.0f;
- defaultOptions.Width = 15.0f;
-
- return defaultOptions;
- }
-
- private void LoadPreferences()
- {
- show = EditorPrefs.GetBool(guid + ".show");
- }
-
- private void SavePreferences()
- {
- EditorPrefs.SetBool(guid + ".show", show);
- }
-
- public PolylineBuilder.Options OnInspectorGUI(PolylineBuilder.Options options)
- {
- LoadPreferences();
-
- show = EditorGUILayout.Foldout(show, "Polyline builder options");
-
- if (!show)
- {
- SavePreferences();
- return options;
- }
-
- options.Width = EditorGUILayout.FloatField("Width: ", options.Width);
- options.MaxHeight = EditorGUILayout.FloatField("Max Height: ", options.MaxHeight);
- options.Extrusion = (PolygonBuilder.ExtrusionType)EditorGUILayout.EnumPopup("Extrusion type: ", options.Extrusion);
- options.Enabled = EditorGUILayout.Toggle("Enabled: ", options.Enabled);
-
- SavePreferences();
-
- return options;
- }
-}
diff --git a/Assets/Editor/PolylineBuilderEditor.cs.meta b/Assets/Editor/PolylineBuilderEditor.cs.meta
deleted file mode 100644
index 64dc3449..00000000
--- a/Assets/Editor/PolylineBuilderEditor.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 0af68d1d0a17647b6a25209cd30b9bfe
-timeCreated: 1500930794
-licenseType: Free
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/Editor/StyleEditor.cs b/Assets/Editor/StyleEditor.cs
deleted file mode 100644
index ff76c55f..00000000
--- a/Assets/Editor/StyleEditor.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using UnityEngine;
-using UnityEditor;
-using Mapzen;
-using Mapzen.Unity;
-using Mapzen.VectorData.Filters;
-using System.Collections.Generic;
-using System.Linq;
-using System;
-
-[Serializable]
-public class StyleEditor : EditorBase
-{
- [SerializeField]
- private string filterName = "";
-
- [SerializeField]
- private List filterStyleEditors;
-
- [SerializeField]
- private FeatureStyle style;
-
- [SerializeField]
- private bool showLayerFoldout;
-
- private List mapzenLayers = new List(new string[] {
- "boundaries", "buildings", "earth", "landuse", "places", "pois", "roads", "transit", "water",
- });
-
- [SerializeField]
- private List customLayers = new List();
-
- public FeatureStyle Style
- {
- get { return style; }
- }
-
- public StyleEditor(FeatureStyle style)
- : base()
- {
- this.filterStyleEditors = new List();
- this.style = style;
-
- foreach (var filterStyle in style.FilterStyles)
- {
- filterStyleEditors.Add(new FilterStyleEditor(filterStyle));
- }
- }
-
- public void OnInspectorGUI()
- {
- EditorGUILayout.BeginHorizontal();
- {
- filterName = EditorGUILayout.TextField("Filter name: ", filterName);
-
- EditorConfig.SetColor(EditorConfig.AddButtonColor);
- if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth))
- {
- // Filters within a style are identified by their filter name
- var queryFilterStyleName = style.FilterStyles.Where(filterStyle => filterStyle.Name == filterName);
-
- if (filterName.Length == 0)
- {
- Debug.LogError("The filter name can't be empty");
- }
- else if (queryFilterStyleName.Count() > 0)
- {
- Debug.LogError("Filter with name " + filterName + " already exists");
- }
- else
- {
- var filterStyle = new FeatureStyle.FilterStyle(filterName);
- style.AddFilterStyle(filterStyle);
- filterStyleEditors.Add(new FilterStyleEditor(filterStyle));
- }
- }
- EditorConfig.ResetColor();
- }
- EditorGUILayout.EndHorizontal();
-
- EditorGUI.indentLevel++;
-
- for (int i = filterStyleEditors.Count - 1; i >= 0; i--)
- {
- var editor = filterStyleEditors[i];
- var filterStyle = editor.FilterStyle;
-
- var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), filterStyle.Name);
-
- if (state.show)
- {
- List layers = new List();
- // Merge custom and mapzen layers
- layers.AddRange(mapzenLayers);
- layers.AddRange(customLayers);
-
- editor.OnInspectorGUI(layers);
- }
-
- if (state.markedForDeletion)
- {
- style.RemoveFilterStyle(filterStyle);
-
- // Remove the editor for this filter
- filterStyleEditors.RemoveAt(i);
- }
- }
-
- EditorGUI.indentLevel--;
- }
-}
diff --git a/Assets/Editor.meta b/Assets/Mapzen/Editor.meta
similarity index 67%
rename from Assets/Editor.meta
rename to Assets/Mapzen/Editor.meta
index 2049bdaf..744c12a4 100644
--- a/Assets/Editor.meta
+++ b/Assets/Mapzen/Editor.meta
@@ -1,7 +1,7 @@
fileFormatVersion: 2
-guid: f41e6076f043149d091a13c6cd03e61c
+guid: ba408ee1922154c97aa65fe76a04c4c8
folderAsset: yes
-timeCreated: 1499454478
+timeCreated: 1510337917
licenseType: Free
DefaultImporter:
userData:
diff --git a/Assets/Mapzen/Editor/BuilderEditor.cs b/Assets/Mapzen/Editor/BuilderEditor.cs
new file mode 100644
index 00000000..a2a69dd4
--- /dev/null
+++ b/Assets/Mapzen/Editor/BuilderEditor.cs
@@ -0,0 +1,100 @@
+using UnityEngine;
+using UnityEditor;
+using Mapzen;
+using Mapzen.Unity;
+using System.Linq;
+using System;
+
+namespace Mapzen.Editor
+{
+ [Serializable]
+ public class BuilderEditor : EditorBase
+ {
+ public enum BuilderType
+ {
+ Polygons,
+ Polylines,
+ }
+
+ [SerializeField]
+ private PolygonBuilder.Options polygonBuilderOptions;
+
+ [SerializeField]
+ private PolylineBuilder.Options polylineBuilderOptions;
+
+ public string Name;
+ public BuilderType Type;
+
+ public PolylineBuilder.Options PolylineBuilderOptions
+ {
+ get { return polylineBuilderOptions; }
+ }
+
+ public PolygonBuilder.Options PolygonBuilderOptions
+ {
+ get { return polygonBuilderOptions; }
+ }
+
+ public BuilderEditor(PolylineBuilder.Options options)
+ : base()
+ {
+ this.polylineBuilderOptions = options;
+ this.Type = BuilderType.Polylines;
+ this.Name = this.Type.ToString();
+ }
+
+ public BuilderEditor(PolygonBuilder.Options options)
+ : base()
+ {
+ this.polygonBuilderOptions = options;
+ this.Type = BuilderType.Polygons;
+ this.Name = this.Type.ToString();
+ }
+
+ public BuilderEditor(BuilderType type)
+ : base()
+ {
+ this.Type = type;
+ switch (Type) {
+ case BuilderType.Polylines:
+ this.polylineBuilderOptions = new PolylineBuilder.Options();
+ this.polylineBuilderOptions.Extrusion = PolygonBuilder.ExtrusionType.TopAndSides;
+ this.polylineBuilderOptions.Enabled = true;
+ this.polylineBuilderOptions.MaxHeight = 3.0f;
+ this.polylineBuilderOptions.MiterLimit = 3.0f;
+ this.polylineBuilderOptions.Width = 15.0f;
+ this.polylineBuilderOptions.Material = new Material(Shader.Find("Diffuse"));
+ break;
+ case BuilderType.Polygons:
+ this.polygonBuilderOptions = new PolygonBuilder.Options();
+ this.polygonBuilderOptions.Extrusion = PolygonBuilder.ExtrusionType.TopAndSides;
+ this.polygonBuilderOptions.Enabled = true;
+ this.polygonBuilderOptions.UVMode = UVMode.Tile;
+ this.polygonBuilderOptions.MaxHeight = 0.0f;
+ this.polygonBuilderOptions.Material = new Material(Shader.Find("Diffuse"));
+ break;
+ }
+ this.Name = this.Type.ToString();
+ }
+
+ public override void OnInspectorGUI()
+ {
+ switch (Type) {
+ case BuilderType.Polylines:
+ polylineBuilderOptions.Width = EditorGUILayout.FloatField("Width: ", polylineBuilderOptions.Width);
+ polylineBuilderOptions.MaxHeight = EditorGUILayout.FloatField("Max Height: ", polylineBuilderOptions.MaxHeight);
+ polylineBuilderOptions.Extrusion = (PolygonBuilder.ExtrusionType)EditorGUILayout.EnumPopup("Extrusion type: ", polylineBuilderOptions.Extrusion);
+ polylineBuilderOptions.Material = EditorGUILayout.ObjectField("Material:", polylineBuilderOptions.Material, typeof(Material)) as Material;
+ polylineBuilderOptions.Enabled = EditorGUILayout.Toggle("Enabled: ", polylineBuilderOptions.Enabled);
+ break;
+ case BuilderType.Polygons:
+ polygonBuilderOptions.MaxHeight = EditorGUILayout.FloatField("Max Height: ", polygonBuilderOptions.MaxHeight);
+ polygonBuilderOptions.Extrusion = (PolygonBuilder.ExtrusionType)EditorGUILayout.EnumPopup("Extrusion type: ", polygonBuilderOptions.Extrusion);
+ polygonBuilderOptions.Material = EditorGUILayout.ObjectField("Material:", polygonBuilderOptions.Material, typeof(Material)) as Material;
+ polygonBuilderOptions.UVMode = (UVMode)EditorGUILayout.EnumPopup("UV Mode:", polygonBuilderOptions.UVMode);
+ polygonBuilderOptions.Enabled = EditorGUILayout.Toggle("Enabled: ", polygonBuilderOptions.Enabled);
+ break;
+ }
+ }
+ }
+}
diff --git a/Assets/Editor/PolygonBuilderEditor.cs.meta b/Assets/Mapzen/Editor/BuilderEditor.cs.meta
similarity index 76%
rename from Assets/Editor/PolygonBuilderEditor.cs.meta
rename to Assets/Mapzen/Editor/BuilderEditor.cs.meta
index c74acdfa..b1062f69 100644
--- a/Assets/Editor/PolygonBuilderEditor.cs.meta
+++ b/Assets/Mapzen/Editor/BuilderEditor.cs.meta
@@ -1,6 +1,6 @@
fileFormatVersion: 2
-guid: 380ea23500a1d4b37a07202fffb702fc
-timeCreated: 1500930794
+guid: f199b7cb07c4a4e8fb8a5dd23f85716f
+timeCreated: 1510095082
licenseType: Free
MonoImporter:
serializedVersion: 2
diff --git a/Assets/Mapzen/Editor/EditorBase.cs b/Assets/Mapzen/Editor/EditorBase.cs
new file mode 100644
index 00000000..af555acd
--- /dev/null
+++ b/Assets/Mapzen/Editor/EditorBase.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace Mapzen.Editor
+{
+ ///
+ /// Base class for editor, each editor has a unique guid used
+ /// for saving custom preferences in the Unity editor prefs.
+ ///
+ public abstract class EditorBase
+ {
+ protected Guid guid;
+
+ public EditorBase()
+ {
+ this.guid = Guid.NewGuid();
+ }
+
+ public Guid GUID
+ {
+ get { return guid; }
+ }
+
+ public abstract void OnInspectorGUI();
+ }
+}
diff --git a/Assets/Editor/EditorBase.cs.meta b/Assets/Mapzen/Editor/EditorBase.cs.meta
similarity index 100%
rename from Assets/Editor/EditorBase.cs.meta
rename to Assets/Mapzen/Editor/EditorBase.cs.meta
diff --git a/Assets/Mapzen/Editor/EditorConfig.cs b/Assets/Mapzen/Editor/EditorConfig.cs
new file mode 100644
index 00000000..9a4fd39a
--- /dev/null
+++ b/Assets/Mapzen/Editor/EditorConfig.cs
@@ -0,0 +1,46 @@
+using System;
+using UnityEditor;
+using UnityEngine;
+
+namespace Mapzen.Editor
+{
+ ///
+ /// Styling configuration for the editor.
+ ///
+ public class EditorConfig
+ {
+ public static Color AddButtonColor = new Color(0.8f, 0.8f, 0.8f);
+
+ public static Color DownloadButtonEnabledColor = new Color(0.35f, 0.80f, 0.30f);
+
+ public static Color DownloadButtonDisabledColor = new Color(0.45f, 0.45f, 0.45f);
+
+ public static Color RemoveButtonColor = new Color(0.5f, 0.5f, 0.5f);
+
+ public static GUILayoutOption SmallButtonWidth = GUILayout.Width(50.0f);
+
+ public static GUIContent AddButtonContent = new GUIContent("+", "Add");
+
+ public static GUIContent RemoveButtonContent = new GUIContent("-", "Remove");
+
+ public static Color DefaultColor;
+
+ ///
+ /// Globally sets the color of the GUI, saves the current color.
+ ///
+ /// Color.
+ public static void SetColor(Color color)
+ {
+ DefaultColor = GUI.color;
+ GUI.color = color;
+ }
+
+ ///
+ /// Globally resets the color of the GUI to its previous state.
+ ///
+ public static void ResetColor()
+ {
+ GUI.color = DefaultColor;
+ }
+ }
+}
diff --git a/Assets/Editor/EditorConfig.cs.meta b/Assets/Mapzen/Editor/EditorConfig.cs.meta
similarity index 100%
rename from Assets/Editor/EditorConfig.cs.meta
rename to Assets/Mapzen/Editor/EditorConfig.cs.meta
diff --git a/Assets/Mapzen/Editor/FeatureStyleEditor.cs b/Assets/Mapzen/Editor/FeatureStyleEditor.cs
new file mode 100644
index 00000000..da684d76
--- /dev/null
+++ b/Assets/Mapzen/Editor/FeatureStyleEditor.cs
@@ -0,0 +1,34 @@
+using UnityEditor;
+using UnityEngine;
+using System;
+using Mapzen;
+using Mapzen.Unity;
+
+namespace Mapzen.Editor
+{
+ [CustomEditor(typeof(FeatureStyle))]
+ public class FeatureStyleEditor : UnityEditor.Editor
+ {
+ private FeatureStyle featureStyle;
+ private StyleEditor styleEditor;
+
+ void OnEnable()
+ {
+ featureStyle = (FeatureStyle)target;
+ styleEditor = featureStyle.Editor as StyleEditor;
+
+ if (styleEditor == null)
+ {
+ styleEditor = new StyleEditor(featureStyle);
+ featureStyle.Editor = styleEditor;
+ }
+ }
+
+ public override void OnInspectorGUI()
+ {
+ styleEditor.OnInspectorGUI();
+
+ EditorUtility.SetDirty(featureStyle);
+ }
+ }
+}
diff --git a/Assets/Editor/FeatureStyleEditor.cs.meta b/Assets/Mapzen/Editor/FeatureStyleEditor.cs.meta
similarity index 100%
rename from Assets/Editor/FeatureStyleEditor.cs.meta
rename to Assets/Mapzen/Editor/FeatureStyleEditor.cs.meta
diff --git a/Assets/Mapzen/Editor/FilterStyleEditor.cs b/Assets/Mapzen/Editor/FilterStyleEditor.cs
new file mode 100644
index 00000000..99904316
--- /dev/null
+++ b/Assets/Mapzen/Editor/FilterStyleEditor.cs
@@ -0,0 +1,149 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using Mapzen;
+using Mapzen.Unity;
+using Mapzen.VectorData.Filters;
+using UnityEditor;
+using UnityEngine;
+
+namespace Mapzen.Editor
+{
+ [SerializeField]
+ public class FilterStyleEditor : EditorBase
+ {
+ [SerializeField]
+ private int selectedLayer;
+
+ [SerializeField]
+ private FeatureStyle.Matcher.Type selectedMatcherType;
+
+ [SerializeField]
+ private List layerStyleEditors;
+
+ [SerializeField]
+ private MatcherEditor matcherEditor;
+
+ [SerializeField]
+ private FeatureStyle.FilterStyle filterStyle;
+
+ public FeatureStyle.FilterStyle FilterStyle
+ {
+ get { return filterStyle; }
+ }
+
+ private static List mapzenLayers = new List(new string[] {
+ "boundaries", "buildings", "earth", "landuse", "places", "pois", "roads", "transit", "water",
+ });
+
+ public FilterStyleEditor(FeatureStyle.FilterStyle filterStyle)
+ : base()
+ {
+ this.filterStyle = filterStyle;
+ this.layerStyleEditors = new List();
+
+ foreach (var layerStyle in filterStyle.LayerStyles)
+ {
+ layerStyleEditors.Add(new LayerStyleEditor(layerStyle));
+ }
+
+ if (filterStyle.Matcher != null)
+ {
+ selectedMatcherType = filterStyle.Matcher.MatcherType;
+ this.matcherEditor = new MatcherEditor(filterStyle.Matcher);
+ }
+ }
+
+ private void AddLayerStyleLayout(FeatureStyle.FilterStyle filterStyle, string name)
+ {
+ EditorConfig.SetColor(EditorConfig.AddButtonColor);
+ if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth))
+ {
+ // Layers within a filter are identifier by their layer name
+ var queryLayer = filterStyle.LayerStyles.Where(layerStyle => name == layerStyle.LayerName);
+
+ if (name.Length == 0)
+ {
+ Debug.LogError("Layer name can't be empty");
+ }
+ else if (queryLayer.Count() > 0)
+ {
+ Debug.LogError("A layer with name " + name + " already exists");
+ }
+ else
+ {
+ var layerStyle = new FeatureStyle.LayerStyle(name);
+
+ filterStyle.LayerStyles.Add(layerStyle);
+
+ // Create the associated layer editor
+ layerStyleEditors.Add(new LayerStyleEditor(layerStyle));
+ }
+ }
+ EditorConfig.ResetColor();
+ }
+
+ public override void OnInspectorGUI()
+ {
+ // Default layers
+ EditorGUILayout.BeginHorizontal();
+ {
+ selectedLayer = EditorGUILayout.Popup("Default layer:", selectedLayer, mapzenLayers.ToArray());
+ AddLayerStyleLayout(filterStyle, mapzenLayers[selectedLayer]);
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUI.indentLevel++;
+
+ for (int i = layerStyleEditors.Count - 1; i >= 0; i--)
+ {
+ var editor = layerStyleEditors[i];
+ var layerStyling = editor.LayerStyle;
+
+ var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), layerStyling.LayerName);
+
+ if (state.show)
+ {
+ editor.OnInspectorGUI();
+ }
+
+ if (state.markedForDeletion)
+ {
+ // Remove the layer from the filter styles
+ filterStyle.LayerStyles.Remove(layerStyling);
+
+ // Remove the associated layer editor
+ layerStyleEditors.RemoveAt(i);
+ }
+ }
+
+ EditorGUI.indentLevel--;
+
+ var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast();
+ var matcherTypeStringList = matcherTypeList.Select(type => type.ToString());
+ var oldType = selectedMatcherType;
+
+ selectedMatcherType = (FeatureStyle.Matcher.Type)EditorGUILayout.Popup("Matcher:",
+ (int)selectedMatcherType, matcherTypeStringList.ToArray());
+
+ if (selectedMatcherType != oldType)
+ {
+ matcherEditor = new MatcherEditor(new FeatureStyle.Matcher(selectedMatcherType));
+ }
+ else
+ {
+ if (selectedMatcherType == FeatureStyle.Matcher.Type.None)
+ {
+ matcherEditor = null;
+ }
+ }
+
+ if (matcherEditor != null)
+ {
+ matcherEditor.OnInspectorGUI();
+
+ filterStyle.Matcher = matcherEditor.Matcher;
+ }
+ }
+ }
+}
diff --git a/Assets/Editor/FilterStyleEditor.cs.meta b/Assets/Mapzen/Editor/FilterStyleEditor.cs.meta
similarity index 100%
rename from Assets/Editor/FilterStyleEditor.cs.meta
rename to Assets/Mapzen/Editor/FilterStyleEditor.cs.meta
diff --git a/Assets/Mapzen/Editor/FoldoutEditor.cs b/Assets/Mapzen/Editor/FoldoutEditor.cs
new file mode 100644
index 00000000..d5a6e025
--- /dev/null
+++ b/Assets/Mapzen/Editor/FoldoutEditor.cs
@@ -0,0 +1,57 @@
+using System;
+using UnityEditor;
+using UnityEngine;
+
+namespace Mapzen.Editor
+{
+ public class FoldoutEditor
+ {
+ public class State
+ {
+ // Whether the foldout panel is shown
+ public bool show;
+ // Whether the foldout panel is marked for deletion
+ public bool markedForDeletion;
+
+ public State()
+ {
+ this.markedForDeletion = false;
+ this.show = false;
+ }
+ }
+
+ public static bool LoadPreferences(string editorIdentifier)
+ {
+ return EditorPrefs.GetBool(editorIdentifier + ".show");
+ }
+
+ public static void SavePrefences(string editorIdentifier, bool show)
+ {
+ EditorPrefs.SetBool(editorIdentifier + ".show", show);
+ }
+
+ public static State OnInspectorGUI(string editorIdentifier, string foldoutName)
+ {
+ var state = new State();
+
+ state.show = LoadPreferences(editorIdentifier);
+
+ EditorGUILayout.BeginHorizontal();
+ {
+ state.show = EditorGUILayout.Foldout(state.show, foldoutName);
+
+ EditorConfig.SetColor(EditorConfig.RemoveButtonColor);
+ if (GUILayout.Button(EditorConfig.RemoveButtonContent, EditorConfig.SmallButtonWidth))
+ {
+ state.markedForDeletion = true;
+ }
+ EditorConfig.ResetColor();
+ }
+ EditorGUILayout.EndHorizontal();
+
+ SavePrefences(editorIdentifier, state.show);
+
+ return state;
+ }
+ }
+}
diff --git a/Assets/Editor/FoldoutEditor.cs.meta b/Assets/Mapzen/Editor/FoldoutEditor.cs.meta
similarity index 100%
rename from Assets/Editor/FoldoutEditor.cs.meta
rename to Assets/Mapzen/Editor/FoldoutEditor.cs.meta
diff --git a/Assets/Mapzen/Editor/LayerStyleEditor.cs b/Assets/Mapzen/Editor/LayerStyleEditor.cs
new file mode 100644
index 00000000..a0e98993
--- /dev/null
+++ b/Assets/Mapzen/Editor/LayerStyleEditor.cs
@@ -0,0 +1,83 @@
+using System;
+using Mapzen;
+using Mapzen.Unity;
+using UnityEditor;
+using UnityEngine;
+using System.Collections.Generic;
+
+namespace Mapzen.Editor
+{
+ [SerializeField]
+ public class LayerStyleEditor : EditorBase
+ {
+ [SerializeField]
+ private List builderEditors;
+
+ [SerializeField]
+ private FeatureStyle.LayerStyle layerStyle;
+
+ [SerializeField]
+ private BuilderEditor.BuilderType selectedBuilderType;
+
+ public FeatureStyle.LayerStyle LayerStyle
+ {
+ get { return layerStyle; }
+ }
+
+ public LayerStyleEditor(FeatureStyle.LayerStyle layerStyle)
+ : base()
+ {
+ this.layerStyle = layerStyle;
+ this.builderEditors = new List();
+
+ foreach (var options in layerStyle.PolygonBuilderOptions)
+ {
+ this.builderEditors.Add(new BuilderEditor(options));
+ }
+
+ foreach (var options in layerStyle.PolylineBuilderOptions)
+ {
+ this.builderEditors.Add(new BuilderEditor(options));
+ }
+ }
+
+ public override void OnInspectorGUI()
+ {
+ EditorGUILayout.BeginHorizontal();
+ {
+ selectedBuilderType = (BuilderEditor.BuilderType)EditorGUILayout.EnumPopup("Add builder", selectedBuilderType);
+
+ EditorConfig.SetColor(EditorConfig.AddButtonColor);
+ if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth))
+ {
+ var editor = new BuilderEditor(selectedBuilderType);
+ layerStyle.PolygonBuilderOptions.Add(editor.PolygonBuilderOptions);
+ layerStyle.PolylineBuilderOptions.Add(editor.PolylineBuilderOptions);
+ builderEditors.Add(editor);
+ }
+ EditorConfig.ResetColor();
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUI.indentLevel++;
+ for (int i = builderEditors.Count - 1; i >= 0; --i)
+ {
+ var editor = builderEditors[i];
+ var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), editor.Name);
+
+ if (state.show)
+ {
+ editor.OnInspectorGUI();
+ }
+
+ if (state.markedForDeletion)
+ {
+ builderEditors.RemoveAt(i);
+ layerStyle.PolygonBuilderOptions.Remove(editor.PolygonBuilderOptions);
+ layerStyle.PolylineBuilderOptions.Remove(editor.PolylineBuilderOptions);
+ }
+ }
+ EditorGUI.indentLevel--;
+ }
+ }
+}
diff --git a/Assets/Editor/LayerStyleEditor.cs.meta b/Assets/Mapzen/Editor/LayerStyleEditor.cs.meta
similarity index 100%
rename from Assets/Editor/LayerStyleEditor.cs.meta
rename to Assets/Mapzen/Editor/LayerStyleEditor.cs.meta
diff --git a/Assets/Mapzen/Editor/MapzenMapEditor.cs b/Assets/Mapzen/Editor/MapzenMapEditor.cs
new file mode 100644
index 00000000..0982c97c
--- /dev/null
+++ b/Assets/Mapzen/Editor/MapzenMapEditor.cs
@@ -0,0 +1,180 @@
+using UnityEngine;
+using System.Linq;
+using System.Collections.Generic;
+using Mapzen;
+using UnityEditor;
+
+namespace Mapzen.Editor
+{
+ [CustomEditor(typeof(MapzenMap))]
+ public class MapzenMapEditor : UnityEditor.Editor
+ {
+ private MapzenMap mapzenMap;
+ private bool showTileDataFoldout = false;
+ private bool showRegionScaleRatioFoldout = false;
+
+ void OnEnable()
+ {
+ this.mapzenMap = (MapzenMap)target;
+ }
+
+ public override void OnInspectorGUI()
+ {
+ LoadPreferences();
+
+ TileDataFoldout();
+
+ RegionScaleRatioFoldout();
+
+ base.OnInspectorGUI();
+
+ bool valid = IsValid();
+
+ EditorConfig.SetColor(valid ?
+ EditorConfig.DownloadButtonEnabledColor :
+ EditorConfig.DownloadButtonDisabledColor);
+
+ if (GUILayout.Button("Download"))
+ {
+ if (valid)
+ {
+ LogWarnings();
+
+ mapzenMap.DownloadTiles();
+ }
+ else
+ {
+ LogErrors();
+ }
+ }
+
+ EditorConfig.ResetColor();
+
+ SavePreferences();
+ }
+
+ private void SceneGroupToggle(MapzenMap mapzenMap, SceneGroup.Type type)
+ {
+ bool isSet = SceneGroup.Test(type, mapzenMap.GroupOptions);
+ isSet = EditorGUILayout.Toggle(type.ToString(), isSet);
+
+ mapzenMap.GroupOptions = isSet ?
+ mapzenMap.GroupOptions | type :
+ mapzenMap.GroupOptions & ~type;
+ }
+
+ private void TileDataFoldout()
+ {
+ showTileDataFoldout = EditorGUILayout.Foldout(showTileDataFoldout, "Tile data");
+ if (!showTileDataFoldout)
+ {
+ return;
+ }
+
+ GUILayout.Label("Group by:");
+
+ EditorGUI.indentLevel++;
+
+ EditorGUILayout.BeginHorizontal();
+ SceneGroupToggle(mapzenMap, SceneGroup.Type.Feature);
+ SceneGroupToggle(mapzenMap, SceneGroup.Type.Filter);
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.BeginHorizontal();
+ SceneGroupToggle(mapzenMap, SceneGroup.Type.Layer);
+ SceneGroupToggle(mapzenMap, SceneGroup.Type.Tile);
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUI.indentLevel--;
+ }
+
+ private void UnitScaleToggle(MapzenMap mapzenMap, RegionScaleUnits.Units unit)
+ {
+ bool isSet = RegionScaleUnits.Test(unit, mapzenMap.RegionScaleUnit);
+ isSet = EditorGUILayout.Toggle(unit.ToString(), isSet);
+
+ mapzenMap.RegionScaleUnit = isSet ? unit : mapzenMap.RegionScaleUnit;
+ }
+
+ private void RegionScaleRatioFoldout()
+ {
+ showRegionScaleRatioFoldout = EditorGUILayout.Foldout(showRegionScaleRatioFoldout, "Region Scale Ratio");
+ if (!showRegionScaleRatioFoldout)
+ {
+ return;
+ }
+
+ mapzenMap.RegionScaleRatio = EditorGUILayout.FloatField("Scale: ", mapzenMap.RegionScaleRatio);
+ GUILayout.Label("Choose world scale units: ");
+ EditorGUI.indentLevel++;
+
+ EditorGUILayout.BeginHorizontal();
+ UnitScaleToggle(mapzenMap, RegionScaleUnits.Units.Meters);
+ UnitScaleToggle(mapzenMap, RegionScaleUnits.Units.KiloMeters);
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.BeginHorizontal();
+ UnitScaleToggle(mapzenMap, RegionScaleUnits.Units.Miles);
+ UnitScaleToggle(mapzenMap, RegionScaleUnits.Units.Feet);
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUI.indentLevel--;
+ }
+
+ private void LoadPreferences()
+ {
+ string key = typeof(MapzenMapEditor).Name;
+ showTileDataFoldout = EditorPrefs.GetBool(key + ".showTileDataFoldout");
+ showRegionScaleRatioFoldout = EditorPrefs.GetBool(key + ".showRegionScaleRatioFoldout");
+ }
+
+ private void SavePreferences()
+ {
+ string key = typeof(MapzenMapEditor).Name;
+ EditorPrefs.SetBool(key + ".showTileDataFoldout", showTileDataFoldout);
+ EditorPrefs.SetBool(key + ".showRegionScaleRatioFoldout", showRegionScaleRatioFoldout);
+ }
+
+ private bool IsValid()
+ {
+ return mapzenMap.RegionName.Length > 0 && mapzenMap.FeatureStyling.Count > 0;
+ }
+
+ private void LogWarnings()
+ {
+ foreach (var style in mapzenMap.FeatureStyling)
+ {
+ if (style == null)
+ {
+ Debug.LogWarning("'Null' style provided in feature styling collection");
+ continue;
+ }
+
+ if (style.FilterStyles.Count == 0)
+ {
+ Debug.LogWarning("The style " + style.name + " has no filter");
+ }
+
+ foreach (var filterStyle in style.FilterStyles)
+ {
+ if (filterStyle.GetFilter().CollectionNameSet.Count == 0)
+ {
+ Debug.LogWarning("The style " + style.name + " has a filter selecting no layer");
+ }
+ }
+ }
+ }
+
+ private void LogErrors()
+ {
+ if (mapzenMap.RegionName.Length == 0)
+ {
+ Debug.LogError("Make sure to give a region name");
+ }
+
+ if (mapzenMap.FeatureStyling.Count == 0)
+ {
+ Debug.LogError("Make sure to create at least one style");
+ }
+ }
+ }
+}
diff --git a/Assets/Editor/MapzenMapEditor.cs.meta b/Assets/Mapzen/Editor/MapzenMapEditor.cs.meta
similarity index 100%
rename from Assets/Editor/MapzenMapEditor.cs.meta
rename to Assets/Mapzen/Editor/MapzenMapEditor.cs.meta
diff --git a/Assets/Mapzen/Editor/MatcherEditor.cs b/Assets/Mapzen/Editor/MatcherEditor.cs
new file mode 100644
index 00000000..5c518c94
--- /dev/null
+++ b/Assets/Mapzen/Editor/MatcherEditor.cs
@@ -0,0 +1,135 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using Mapzen;
+using Mapzen.Unity;
+using Mapzen.VectorData.Filters;
+using UnityEditor;
+using UnityEngine;
+
+namespace Mapzen.Editor
+{
+ [Serializable]
+ public class MatcherEditor : EditorBase
+ {
+ [SerializeField]
+ private FeatureStyle.Matcher.Type selectedMatcherType;
+
+ [SerializeField]
+ private FeatureStyle.Matcher matcher;
+
+ [SerializeField]
+ private List matcherEditors;
+
+ public FeatureStyle.Matcher Matcher
+ {
+ get { return matcher; }
+ }
+
+ public MatcherEditor(FeatureStyle.Matcher matcher)
+ : base()
+ {
+ this.matcher = matcher;
+ this.matcherEditors = new List();
+
+ foreach (var matcherChild in matcher.Matchers)
+ {
+ this.matcherEditors.Add(new MatcherEditor(matcherChild));
+ }
+ }
+
+ private MatcherEditor AddMatcherLayout()
+ {
+ MatcherEditor editor = null;
+
+ EditorGUILayout.BeginHorizontal();
+ {
+ var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast();
+ var matcherTypeStringList = matcherTypeList.Select(type => type.ToString());
+
+ selectedMatcherType = (FeatureStyle.Matcher.Type)EditorGUILayout.Popup("Matcher:",
+ (int)selectedMatcherType, matcherTypeStringList.ToArray());
+
+ EditorConfig.SetColor(EditorConfig.AddButtonColor);
+ if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth)
+ && selectedMatcherType != FeatureStyle.Matcher.Type.None)
+ {
+ var matcherType = (FeatureStyle.Matcher.Type)selectedMatcherType;
+ var newMatcher = new FeatureStyle.Matcher(matcherType);
+
+ editor = new MatcherEditor(newMatcher);
+ matcher.Matchers.Add(newMatcher);
+ }
+ EditorConfig.ResetColor();
+ }
+ EditorGUILayout.EndHorizontal();
+
+ return editor;
+ }
+
+ public override void OnInspectorGUI()
+ {
+ EditorGUI.indentLevel++;
+
+ if (matcher.IsCompound())
+ {
+ var editor = AddMatcherLayout();
+ if (editor != null)
+ {
+ matcherEditors.Add(editor);
+ }
+ }
+ else
+ {
+ switch (matcher.MatcherType)
+ {
+ case FeatureStyle.Matcher.Type.Property:
+ matcher.HasProperty = EditorGUILayout.TextField("Has property:", matcher.HasProperty);
+ break;
+
+ case FeatureStyle.Matcher.Type.PropertyRange:
+ matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
+ EditorGUILayout.BeginHorizontal();
+ matcher.MinRange = EditorGUILayout.FloatField("min:", matcher.MinRange);
+ matcher.MinRangeEnabled = EditorGUILayout.Toggle(matcher.MinRangeEnabled);
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.BeginHorizontal();
+ matcher.MaxRange = EditorGUILayout.FloatField("max:", matcher.MaxRange);
+ matcher.MaxRangeEnabled = EditorGUILayout.Toggle(matcher.MaxRangeEnabled);
+ EditorGUILayout.EndHorizontal();
+ break;
+
+ case FeatureStyle.Matcher.Type.PropertyValue:
+ matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
+ matcher.PropertyValue = EditorGUILayout.TextField("Property value:", matcher.PropertyValue);
+ break;
+
+ case FeatureStyle.Matcher.Type.PropertyRegex:
+ matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
+ matcher.RegexPattern = EditorGUILayout.TextField("Regex:", matcher.RegexPattern);
+ break;
+ }
+ }
+
+ for (int i = matcherEditors.Count - 1; i >= 0; i--)
+ {
+ var editor = matcherEditors[i];
+
+ var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), editor.Matcher.MatcherType.ToString());
+
+ if (state.show)
+ {
+ editor.OnInspectorGUI();
+ }
+
+ if (state.markedForDeletion)
+ {
+ matcher.Matchers.Remove(editor.Matcher);
+ matcherEditors.RemoveAt(i);
+ }
+ }
+
+ EditorGUI.indentLevel--;
+ }
+ }
+}
diff --git a/Assets/Editor/MatcherEditor.cs.meta b/Assets/Mapzen/Editor/MatcherEditor.cs.meta
similarity index 100%
rename from Assets/Editor/MatcherEditor.cs.meta
rename to Assets/Mapzen/Editor/MatcherEditor.cs.meta
diff --git a/Assets/Mapzen/Editor/StyleEditor.cs b/Assets/Mapzen/Editor/StyleEditor.cs
new file mode 100644
index 00000000..c6214415
--- /dev/null
+++ b/Assets/Mapzen/Editor/StyleEditor.cs
@@ -0,0 +1,98 @@
+using UnityEngine;
+using UnityEditor;
+using Mapzen;
+using Mapzen.Unity;
+using Mapzen.VectorData.Filters;
+using System.Collections.Generic;
+using System.Linq;
+using System;
+
+namespace Mapzen.Editor
+{
+ [Serializable]
+ public class StyleEditor : EditorBase
+ {
+ [SerializeField]
+ private string filterName = "";
+
+ [SerializeField]
+ private List filterStyleEditors;
+
+ [SerializeField]
+ private FeatureStyle style;
+
+ public FeatureStyle Style
+ {
+ get { return style; }
+ }
+
+ public StyleEditor(FeatureStyle style)
+ : base()
+ {
+ this.filterStyleEditors = new List();
+ this.style = style;
+
+ foreach (var filterStyle in style.FilterStyles)
+ {
+ filterStyleEditors.Add(new FilterStyleEditor(filterStyle));
+ }
+ }
+
+ public override void OnInspectorGUI()
+ {
+ EditorGUILayout.BeginHorizontal();
+ {
+ filterName = EditorGUILayout.TextField("Filter name: ", filterName);
+
+ EditorConfig.SetColor(EditorConfig.AddButtonColor);
+ if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth))
+ {
+ // Filters within a style are identified by their filter name
+ var queryFilterStyleName = style.FilterStyles.Where(filterStyle => filterStyle.Name == filterName);
+
+ if (filterName.Length == 0)
+ {
+ Debug.LogError("The filter name can't be empty");
+ }
+ else if (queryFilterStyleName.Count() > 0)
+ {
+ Debug.LogError("Filter with name " + filterName + " already exists");
+ }
+ else
+ {
+ var filterStyle = new FeatureStyle.FilterStyle(filterName);
+ style.AddFilterStyle(filterStyle);
+ filterStyleEditors.Add(new FilterStyleEditor(filterStyle));
+ }
+ }
+ EditorConfig.ResetColor();
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUI.indentLevel++;
+
+ for (int i = filterStyleEditors.Count - 1; i >= 0; i--)
+ {
+ var editor = filterStyleEditors[i];
+ var filterStyle = editor.FilterStyle;
+
+ var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), filterStyle.Name);
+
+ if (state.show)
+ {
+ editor.OnInspectorGUI();
+ }
+
+ if (state.markedForDeletion)
+ {
+ style.RemoveFilterStyle(filterStyle);
+
+ // Remove the editor for this filter
+ filterStyleEditors.RemoveAt(i);
+ }
+ }
+
+ EditorGUI.indentLevel--;
+ }
+ }
+}
diff --git a/Assets/Editor/StyleEditor.cs.meta b/Assets/Mapzen/Editor/StyleEditor.cs.meta
similarity index 100%
rename from Assets/Editor/StyleEditor.cs.meta
rename to Assets/Mapzen/Editor/StyleEditor.cs.meta
diff --git a/Assets/Mapzen/Unity/FeatureStyle.cs b/Assets/Mapzen/Unity/FeatureStyle.cs
index 5dc9c230..c082976c 100644
--- a/Assets/Mapzen/Unity/FeatureStyle.cs
+++ b/Assets/Mapzen/Unity/FeatureStyle.cs
@@ -17,9 +17,8 @@ public class LayerStyle
[SerializeField]
private string layerName;
- public Material Material;
- public PolygonBuilder.Options PolygonBuilderOptions;
- public PolylineBuilder.Options PolylineBuilderOptions;
+ public List PolygonBuilderOptions;
+ public List PolylineBuilderOptions;
public string LayerName
{
@@ -29,39 +28,8 @@ public string LayerName
public LayerStyle(string layerName)
{
this.layerName = layerName;
- }
-
- public PolygonBuilder.Options GetPolygonOptions(Feature feature, float inverseTileScale)
- {
- var options = PolygonBuilderOptions;
-
- options.Material = this.Material;
-
- if (options.MaxHeight > 0.0f)
- {
- options.MaxHeight *= inverseTileScale;
- }
- else
- {
- object heightValue;
- if (feature.TryGetProperty("height", out heightValue) && heightValue is double)
- {
- options.MaxHeight = (float)((double)heightValue * inverseTileScale);
- }
- }
-
- return options;
- }
-
- public PolylineBuilder.Options GetPolylineOptions(Feature feature, float inverseTileScale)
- {
- var options = PolylineBuilderOptions;
-
- options.Material = this.Material;
- options.Width *= inverseTileScale;
- options.MaxHeight *= inverseTileScale;
-
- return options;
+ this.PolygonBuilderOptions = new List();
+ this.PolylineBuilderOptions = new List();
}
}
diff --git a/Assets/Mapzen/Unity/PolygonBuilder.cs b/Assets/Mapzen/Unity/PolygonBuilder.cs
index 894abc0d..9a478605 100644
--- a/Assets/Mapzen/Unity/PolygonBuilder.cs
+++ b/Assets/Mapzen/Unity/PolygonBuilder.cs
@@ -17,7 +17,7 @@ public enum ExtrusionType
}
[Serializable]
- public struct Options
+ public class Options
{
public Material Material;
public ExtrusionType Extrusion;
@@ -28,16 +28,20 @@ public struct Options
public bool Enabled;
}
- public PolygonBuilder(MeshData outputMeshData, Options options, Matrix4x4 transform)
+ public PolygonBuilder(MeshData outputMeshData, Options options, Matrix4x4 transform, float inverseTileScale, float featureHeight)
{
this.transform = transform;
this.outputMeshData = outputMeshData;
this.options = options;
+ this.inverseTileScale = inverseTileScale;
+ this.featureHeight = featureHeight;
}
private Matrix4x4 transform;
private MeshData outputMeshData;
- private Options options;
+ private readonly Options options;
+ private float inverseTileScale;
+ private float featureHeight;
// Values for the tesselator.
private List coordinates = new List();
@@ -53,12 +57,35 @@ public PolygonBuilder(MeshData outputMeshData, Options options, Matrix4x4 transf
private List extrusionIndices = new List();
private float uCoordinateTotal = 0;
+ private float GetMinHeight()
+ {
+ float minHeight = 0.0f;
+ if (options.MinHeight != 0.0f)
+ {
+ minHeight = options.MinHeight * inverseTileScale;
+ }
+ return minHeight;
+ }
+
+ private float GetMaxHeight()
+ {
+ float maxHeight = featureHeight * inverseTileScale;
+ if (options.MaxHeight != 0.0f)
+ {
+ maxHeight = options.MaxHeight * inverseTileScale;
+ }
+ return maxHeight;
+ }
+
public void OnPoint(Point point)
{
bool buildWalls =
options.Extrusion == ExtrusionType.TopAndSides ||
options.Extrusion == ExtrusionType.SidesOnly;
+ float minHeight = GetMinHeight();
+ float maxHeight = GetMaxHeight();
+
// For all but the first point in each ring, create a quad extending from the
// previous point to the current point and from MinHeight to MaxHeight.
if (buildWalls && pointsInRing > 0)
@@ -71,10 +98,10 @@ public void OnPoint(Point point)
// Increase the u coordinate by the 2D distance between the points.
var uCoordinateNext = uCoordinateTotal + new Vector2(p1.X - p0.X, p1.Y - p0.Y).magnitude;
- var v0 = new Vector3(p0.X, options.MaxHeight, p0.Y);
- var v1 = new Vector3(p1.X, options.MaxHeight, p1.Y);
- var v2 = new Vector3(p0.X, options.MinHeight, p0.Y);
- var v3 = new Vector3(p1.X, options.MinHeight, p1.Y);
+ var v0 = new Vector3(p0.X, maxHeight, p0.Y);
+ var v1 = new Vector3(p1.X, maxHeight, p1.Y);
+ var v2 = new Vector3(p0.X, minHeight, p0.Y);
+ var v3 = new Vector3(p1.X, minHeight, p1.Y);
v0 = this.transform.MultiplyPoint(v0);
v1 = this.transform.MultiplyPoint(v1);
@@ -169,6 +196,8 @@ public void OnBeginPolygon()
public void OnEndPolygon()
{
+ float maxHeight = GetMaxHeight();
+
// First add vertices and indices for extrusions.
outputMeshData.AddElements(extrusionVertices, extrusionUVs, extrusionIndices, options.Material);
@@ -196,7 +225,7 @@ public void OnEndPolygon()
for (int i = 0; i < coordinates.Count; i += 2)
{
- var v = new Vector3(coordinates[i], options.MaxHeight, coordinates[i + 1]);
+ var v = new Vector3(coordinates[i], maxHeight, coordinates[i + 1]);
v = this.transform.MultiplyPoint(v);
vertices.Add(v);
}
diff --git a/Assets/Mapzen/Unity/PolylineBuilder.cs b/Assets/Mapzen/Unity/PolylineBuilder.cs
index 527c5c82..85d6c0ff 100644
--- a/Assets/Mapzen/Unity/PolylineBuilder.cs
+++ b/Assets/Mapzen/Unity/PolylineBuilder.cs
@@ -10,13 +10,13 @@ public class PolylineBuilder : IGeometryHandler
{
private PolygonBuilder polygonBuilder;
private List polyline;
- private Options options;
+ private readonly Options options;
private float uvDistance;
-
+ private float inverseTileScale;
[Serializable]
- public struct Options
+ public class Options
{
public Material Material;
public PolygonBuilder.ExtrusionType Extrusion;
@@ -27,9 +27,10 @@ public struct Options
public bool Enabled;
}
- public PolylineBuilder(MeshData outputMeshData, Options options, Matrix4x4 transform)
+ public PolylineBuilder(MeshData outputMeshData, Options options, Matrix4x4 transform, float inverseTileScale, float featureHeight)
{
this.options = options;
+ this.inverseTileScale = inverseTileScale;
var polygonOptions = new PolygonBuilder.Options();
polygonOptions.Material = options.Material;
@@ -37,7 +38,7 @@ public PolylineBuilder(MeshData outputMeshData, Options options, Matrix4x4 trans
polygonOptions.MinHeight = options.MinHeight;
polygonOptions.MaxHeight = options.MaxHeight;
- polygonBuilder = new PolygonBuilder(outputMeshData, polygonOptions, transform);
+ polygonBuilder = new PolygonBuilder(outputMeshData, polygonOptions, transform, inverseTileScale, featureHeight);
polyline = new List();
uvDistance = 0.0f;
}
@@ -72,8 +73,8 @@ public void OnEndLineString()
return;
}
- float extrude = options.Width * 0.5f;
- float invWidth = 1.0f / options.Width;
+ float extrude = options.Width * inverseTileScale * 0.5f;
+ float invWidth = 1.0f / (options.Width * inverseTileScale);
if (polyline.Count == 2)
{
diff --git a/Assets/Mapzen/Unity/TileTask.cs b/Assets/Mapzen/Unity/TileTask.cs
index d8e5e2a1..d08feb42 100644
--- a/Assets/Mapzen/Unity/TileTask.cs
+++ b/Assets/Mapzen/Unity/TileTask.cs
@@ -61,8 +61,10 @@ public void Start(List featureStyling, SceneGroup root)
{
var layerStyle = filterStyle.LayerStyles.Find(ls => ls.LayerName == layer.Name);
+ float featureHeight = 0.0f;
string featureName = "";
object identifier;
+ object heightValue;
if (feature.TryGetProperty("id", out identifier))
{
@@ -71,24 +73,37 @@ public void Start(List featureStyling, SceneGroup root)
OnSceneGroupData(SceneGroup.Type.Feature, featureName, layerGroup, ref leaf);
- if (feature.Type == GeometryType.Polygon || feature.Type == GeometryType.MultiPolygon)
+ if (feature.TryGetProperty("height", out heightValue) && heightValue is double)
{
- var polygonOptions = layerStyle.GetPolygonOptions(feature, inverseTileScale);
+ featureHeight = (float)((double)heightValue);
+ }
- if (polygonOptions.Enabled)
+ if (feature.Type == GeometryType.Polygon || feature.Type == GeometryType.MultiPolygon)
+ {
+ foreach (var polygonOptions in layerStyle.PolygonBuilderOptions)
{
- var builder = new PolygonBuilder(leaf.meshData, polygonOptions, transform);
+ if (!polygonOptions.Enabled)
+ {
+ continue;
+ }
+
+ var builder = new PolygonBuilder(leaf.meshData, polygonOptions,
+ transform, inverseTileScale, featureHeight);
feature.HandleGeometry(builder);
}
}
if (feature.Type == GeometryType.LineString || feature.Type == GeometryType.MultiLineString)
{
- var polylineOptions = layerStyle.GetPolylineOptions(feature, inverseTileScale);
-
- if (polylineOptions.Enabled)
+ foreach (var polylineOptions in layerStyle.PolylineBuilderOptions)
{
- var builder = new PolylineBuilder(leaf.meshData, polylineOptions, transform);
+ if (!polylineOptions.Enabled)
+ {
+ continue;
+ }
+
+ var builder = new PolylineBuilder(leaf.meshData, polylineOptions,
+ transform, inverseTileScale, featureHeight);
feature.HandleGeometry(builder);
}
}
diff --git a/Assets/Scenes/DefaultScene.unity b/Assets/Scenes/DefaultScene.unity
index c3e057c0..a79e698b 100644
--- a/Assets/Scenes/DefaultScene.unity
+++ b/Assets/Scenes/DefaultScene.unity
@@ -38,11 +38,11 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
- m_IndirectSpecularColor: {r: 0.44659358, g: 0.49642974, b: 0.574825, a: 1}
+ m_IndirectSpecularColor: {r: 0.4465934, g: 0.49642956, b: 0.57482487, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
- serializedVersion: 9
+ serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
@@ -54,7 +54,7 @@ LightmapSettings:
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
- serializedVersion: 8
+ serializedVersion: 9
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
@@ -87,7 +87,7 @@ LightmapSettings:
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 0}
- m_ShadowMaskMode: 2
+ m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
@@ -139,7 +139,6 @@ MonoBehaviour:
IsStatic: 0
GeneratePhysicMeshCollider: 0
PhysicMaterial: {fileID: 0}
- regionScaleRatio: 0.01
ApiKey: mapzen-MTyWgFy
Area:
min:
@@ -151,8 +150,9 @@ MonoBehaviour:
zoom: 16
RegionName: region_0
featureStyling:
- - {fileID: 11400000, guid: fc13486fe526f434c97435d16023999a, type: 2}
+ - {fileID: 11400000, guid: 9d2ae5fd813fc4063b3c14204f61380c, type: 2}
groupOptions: 4
+ regionScaleUnit: 1
--- !u!4 &349009245
Transform:
m_ObjectHideFlags: 0
diff --git a/Assets/Scenes/DefaultStyle.asset b/Assets/Scenes/DefaultStyle.asset
index f61b78d9..473b8044 100644
--- a/Assets/Scenes/DefaultStyle.asset
+++ b/Assets/Scenes/DefaultStyle.asset
@@ -15,45 +15,28 @@ MonoBehaviour:
- name: filter_0
layerStyles:
- layerName: roads
- Material: {fileID: 2100000, guid: ca945bef7446a48c3a7e6c2241195361, type: 2}
PolygonBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 2
+ - Material: {fileID: 0}
+ Extrusion: 0
+ UVMode: 0
+ MinHeight: 0
+ MaxHeight: 0
+ Enabled: 0
+ - Material: {fileID: 0}
+ Extrusion: 0
+ UVMode: 0
MinHeight: 0
MaxHeight: 0
Enabled: 0
PolylineBuilderOptions:
- Material: {fileID: 0}
+ - Material: {fileID: 2100000, guid: ca945bef7446a48c3a7e6c2241195361, type: 2}
Extrusion: 2
MinHeight: 0
MaxHeight: 3
Width: 15
MiterLimit: 3
Enabled: 1
- filter:
- CollectionNameSet: []
- Matcher:
- type: 7
- matchers: []
- HasProperty: kind
- PropertyValue: major_road
- RegexPattern:
- MinRange: 0
- MaxRange: 0
- MinRangeEnabled: 1
- MaxRangeEnabled: 1
- - name: filter_1
- layerStyles:
- - layerName: roads
- Material: {fileID: 2100000, guid: ce1f4d2f66c614a9489e5ee52bbe34da, type: 2}
- PolygonBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 0
- MinHeight: 0
- MaxHeight: 0
- Enabled: 0
- PolylineBuilderOptions:
- Material: {fileID: 0}
+ - Material: {fileID: 2100000, guid: ce1f4d2f66c614a9489e5ee52bbe34da, type: 2}
Extrusion: 0
MinHeight: 0
MaxHeight: 3
@@ -74,70 +57,22 @@ MonoBehaviour:
MaxRangeEnabled: 1
- name: filter_2
layerStyles:
- - layerName: boundaries
- Material: {fileID: 2100000, guid: 7f88baed2a0f94bb3a42f7bc45b5fcf8, type: 2}
- PolygonBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
- MinHeight: 0
- MaxHeight: 0
- Enabled: 0
- PolylineBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
- MinHeight: 0
- MaxHeight: 3
- Width: 15
- MiterLimit: 3
- Enabled: 1
- - layerName: water
- Material: {fileID: 2100000, guid: bb0267789bf4345c7916b57b125fc6ca, type: 2}
+ - layerName: buildings
PolygonBuilderOptions:
- Material: {fileID: 0}
+ - Material: {fileID: 10302, guid: 0000000000000000f000000000000000, type: 0}
Extrusion: 1
+ UVMode: 1
MinHeight: 0
MaxHeight: 0
Enabled: 1
PolylineBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
- MinHeight: 0
- MaxHeight: 3
- Width: 15
- MiterLimit: 3
- Enabled: 0
- - layerName: earth
- Material: {fileID: 2100000, guid: 0cdfce05273914dd4823f77af6b71663, type: 2}
- PolygonBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
+ - Material: {fileID: 0}
+ Extrusion: 0
MinHeight: 0
MaxHeight: 0
- Enabled: 1
- PolylineBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
- MinHeight: 0
- MaxHeight: 3
- Width: 15
- MiterLimit: 3
+ Width: 0
+ MiterLimit: 0
Enabled: 0
- - layerName: buildings
- Material: {fileID: 2100000, guid: 7f88baed2a0f94bb3a42f7bc45b5fcf8, type: 2}
- PolygonBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
- MinHeight: 0
- MaxHeight: 0
- Enabled: 1
- PolylineBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
- MinHeight: 0
- MaxHeight: 3
- Width: 15
- MiterLimit: 3
- Enabled: 1
filter:
CollectionNameSet: []
Matcher:
@@ -162,21 +97,21 @@ MonoBehaviour:
- name: filter_3
layerStyles:
- layerName: buildings
- Material: {fileID: 2100000, guid: c583580183f69476bbe6cda2361da21e, type: 2}
PolygonBuilderOptions:
- Material: {fileID: 0}
+ - Material: {fileID: 2100000, guid: c583580183f69476bbe6cda2361da21e, type: 2}
Extrusion: 1
+ UVMode: 1
MinHeight: 0
MaxHeight: 0
Enabled: 1
PolylineBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
+ - Material: {fileID: 0}
+ Extrusion: 0
MinHeight: 0
- MaxHeight: 3
- Width: 15
- MiterLimit: 3
- Enabled: 1
+ MaxHeight: 0
+ Width: 0
+ MiterLimit: 0
+ Enabled: 0
filter:
CollectionNameSet: []
Matcher:
@@ -192,19 +127,32 @@ MonoBehaviour:
- name: filter_4
layerStyles:
- layerName: roads
- Material: {fileID: 2100000, guid: f776709bfa7fa4d3a88a6b24cd6c7429, type: 2}
PolygonBuilderOptions:
- Material: {fileID: 0}
- Extrusion: 1
+ - Material: {fileID: 0}
+ Extrusion: 0
+ UVMode: 0
MinHeight: 0
MaxHeight: 0
- Enabled: 1
+ Enabled: 0
+ - Material: {fileID: 0}
+ Extrusion: 0
+ UVMode: 0
+ MinHeight: 0
+ MaxHeight: 0
+ Enabled: 0
PolylineBuilderOptions:
- Material: {fileID: 0}
+ - Material: {fileID: 2100000, guid: ca945bef7446a48c3a7e6c2241195361, type: 2}
+ Extrusion: 2
+ MinHeight: 0
+ MaxHeight: 3
+ Width: 15
+ MiterLimit: 3
+ Enabled: 1
+ - Material: {fileID: 2100000, guid: f776709bfa7fa4d3a88a6b24cd6c7429, type: 2}
Extrusion: 0
MinHeight: 0
- MaxHeight: 1
- Width: 10
+ MaxHeight: 3
+ Width: 15
MiterLimit: 3
Enabled: 1
filter:
@@ -219,3 +167,49 @@ MonoBehaviour:
MaxRange: 0
MinRangeEnabled: 1
MaxRangeEnabled: 1
+ - name: filter_1
+ layerStyles:
+ - layerName: earth
+ PolygonBuilderOptions:
+ - Material: {fileID: 2100000, guid: 0cdfce05273914dd4823f77af6b71663, type: 2}
+ Extrusion: 1
+ UVMode: 1
+ MinHeight: 0
+ MaxHeight: 0
+ Enabled: 1
+ PolylineBuilderOptions:
+ - Material: {fileID: 0}
+ Extrusion: 0
+ MinHeight: 0
+ MaxHeight: 0
+ Width: 0
+ MiterLimit: 0
+ Enabled: 0
+ - layerName: water
+ PolygonBuilderOptions:
+ - Material: {fileID: 2100000, guid: bb0267789bf4345c7916b57b125fc6ca, type: 2}
+ Extrusion: 1
+ UVMode: 1
+ MinHeight: 0
+ MaxHeight: 0
+ Enabled: 1
+ PolylineBuilderOptions:
+ - Material: {fileID: 0}
+ Extrusion: 0
+ MinHeight: 0
+ MaxHeight: 0
+ Width: 0
+ MiterLimit: 0
+ Enabled: 0
+ filter:
+ CollectionNameSet: []
+ Matcher:
+ type: 0
+ matchers: []
+ HasProperty:
+ PropertyValue:
+ RegexPattern:
+ MinRange: 0
+ MaxRange: 0
+ MinRangeEnabled: 0
+ MaxRangeEnabled: 0