From 78f415f8730776ef8e2d6173469435bf51a8bc89 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Tue, 24 Apr 2018 18:29:13 -0700 Subject: [PATCH 01/21] adding the data structure for processing tilejson response --- .../Unity/DataContainers/MapboxEnums.cs | 9 ++ .../Mapbox/Unity/Editor/EditorTileJSONData.cs | 43 ++++++ .../Unity/Editor/EditorTileJSONData.cs.meta | 13 ++ .../Unity/Editor/LayerEditorPopUp.cs.meta | 13 ++ .../Mapbox/Unity/Editor/MapManagerEditor.cs | 128 +++++++++++++++++- sdkproject/Assets/Resources.meta | 10 ++ sdkproject/Assets/StreamingAssets.meta | 10 ++ .../StreamingAssets/build_info.txt.meta | 9 ++ 8 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs create mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs.meta create mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs.meta create mode 100644 sdkproject/Assets/Resources.meta create mode 100644 sdkproject/Assets/StreamingAssets.meta create mode 100644 sdkproject/Assets/StreamingAssets/build_info.txt.meta diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/MapboxEnums.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/MapboxEnums.cs index e35685c45..0043677c9 100644 --- a/sdkproject/Assets/Mapbox/Unity/DataContainers/MapboxEnums.cs +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/MapboxEnums.cs @@ -176,4 +176,13 @@ public enum ColliderType [Description("Sphere collider added to the GameObject.")] SphereCollider, } + + /// + /// Data type for the property name derived from the Mapbox tilset layer + /// + public enum PropertyDataType + { + String, + Number + } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs new file mode 100644 index 000000000..8bb2bfde2 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using Mapbox.Unity.Map; + +public class EditorTileJSONData +{ + + private static EditorTileJSONData _instance; + public static EditorTileJSONData Instance{ + get + { + if (_instance == null) + _instance = new EditorTileJSONData(); + + return _instance; + } + } + + public bool tileJSONLoaded = false; + /// + /// List of data sources (tileset ids) linked to a layer name + /// + public Dictionary> LayerPropertyDictionary = new Dictionary>(); + + /// + /// The description of the property in a layer + /// + public Dictionary PropertyDescriptionDictionary = new Dictionary(); + + /// + /// List of data sources (tileset ids) linked to a layer name + /// + public Dictionary> LayerSourcesDictionary = new Dictionary>(); + + /// + /// The source layers in a dictionary + /// + public Dictionary> SourceLayersDictionary = new Dictionary>(); + + /// + /// The data type of the property name in the layer + /// + public Dictionary PropertyDataTypeDictionary = new Dictionary(); +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs.meta b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs.meta new file mode 100644 index 000000000..93f374770 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 14acf9704f4dd49468b22be126789dd4 +timeCreated: 1524616475 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs.meta b/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs.meta new file mode 100644 index 000000000..8f5d79234 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a57a268b7a7d648928c839acc8c96981 +timeCreated: 1524618245 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 8edf352e2..00b6cf160 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -3,11 +3,31 @@ using UnityEngine; using UnityEditor; using Mapbox.Unity.Map; + using Mapbox.Platform.TilesetTileJSON; + using System.Collections.Generic; [CustomEditor(typeof(AbstractMap))] [CanEditMultipleObjects] public class MapManagerEditor : Editor { + private Rect buttonRect; + /// + /// Gets or sets the layerID + /// + /// true then show general section; otherwise hide, false. + private string TilesetId + { + get + { + return EditorPrefs.GetString("MapManagerEditor_tilesetId"); + } + set + { + EditorPrefs.SetString("MapManagerEditor_tilesetId", value); + } + } + + /// /// Gets or sets a value indicating whether to show general section . /// @@ -161,7 +181,26 @@ public override void OnInspectorGUI() ShowVector = EditorGUILayout.Foldout(ShowVector, "VECTOR"); if (ShowVector) { - ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); + var vectorDataProperty = serializedObject.FindProperty("_vectorData"); + + + var layerProperty = vectorDataProperty.FindPropertyRelative("_layerProperty"); + var layerSourceProperty = layerProperty.FindPropertyRelative("sourceOptions"); + var sourceType = layerProperty.FindPropertyRelative("sourceType"); + VectorSourceType sourceTypeValue = (VectorSourceType)sourceType.enumValueIndex; + string layerString = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id").stringValue; + + if (sourceTypeValue != VectorSourceType.None && !string.IsNullOrEmpty(layerString)) + { + if (string.IsNullOrEmpty(TilesetId) || layerString != TilesetId) + { + EditorTileJSONData tileJSONData = EditorTileJSONData.Instance; + tileJSONData.tileJSONLoaded = false; + TilesetId = layerString; + Unity.MapboxAccess.Instance.TileJSON.Get(layerString,ProcessTileJSONData); + } + } + ShowSection(vectorDataProperty, "_layerProperty"); } GUILayout.EndVertical(); @@ -305,5 +344,92 @@ void PresetARWorldScale(SerializedProperty unifiedMap) vectorSourceType.enumValueIndex = (int)VectorSourceType.MapboxStreets; } + + private PropertyDataType GetPropertyDataType(string propertyDescription) + { + if (propertyDescription.ToLower().Contains("number")) + return PropertyDataType.Number; + + return PropertyDataType.String; + } + + private void ProcessTileJSONData(TileJSONResponse tjr) + { + TileJSONResponse response = tjr; + EditorTileJSONData tileJSONData = EditorTileJSONData.Instance; + + List layerPropertiesList = new List(); + List sourceLayersList = new List(); + + if (response.VectorLayers == null && response.VectorLayers.Length == 0) + { + return; + } + + var propertyName = ""; + var propertyDescription = ""; + var layerSource = ""; + PropertyDataType propertyDataType = PropertyDataType.Number; + + foreach (var layer in response.VectorLayers) + { + var layerName = layer.Id; + layerPropertiesList = new List(); + layerSource = layer.Source; + + foreach (var property in layer.Fields) + { + propertyName = property.Key; + propertyDescription = property.Value; + propertyDataType = GetPropertyDataType(propertyDescription); + layerPropertiesList.Add(propertyName); + + //adding data type for the property to the dictionary + if (tileJSONData.PropertyDataTypeDictionary.ContainsKey(propertyName)) + tileJSONData.PropertyDataTypeDictionary[propertyName] = propertyDataType; + else + tileJSONData.PropertyDataTypeDictionary.Add(propertyName, propertyDataType); + + //adding property descriptions + if (tileJSONData.PropertyDescriptionDictionary.ContainsKey(propertyName)) + tileJSONData.PropertyDescriptionDictionary[propertyName] = propertyDescription; + else + tileJSONData.PropertyDescriptionDictionary.Add(propertyName, propertyDescription); + } + + //loading layerproperty dictionary + if (tileJSONData.LayerPropertyDictionary.ContainsKey(layerName)) + { + tileJSONData.LayerPropertyDictionary[layerName].AddRange(layerPropertiesList); + } + else + { + tileJSONData.LayerPropertyDictionary.Add(layerName, layerPropertiesList); + } + + //loading layer sources + if (tileJSONData.LayerSourcesDictionary.ContainsKey(layerName)) + { + tileJSONData.LayerSourcesDictionary[layerName].Add(layerSource); + } + else + { + tileJSONData.LayerSourcesDictionary.Add(layerName, new List() { layerSource }); + } + + //loading layers to a data source + if (tileJSONData.SourceLayersDictionary.ContainsKey(layerSource)) + { + tileJSONData.SourceLayersDictionary[layerSource].Add(layerName); + } + else + { + tileJSONData.SourceLayersDictionary.Add(layerSource, new List() { layerName }); + } + } + + tileJSONData.tileJSONLoaded = true; + //Debug.Log(tileJSONResponse); + } } } diff --git a/sdkproject/Assets/Resources.meta b/sdkproject/Assets/Resources.meta new file mode 100644 index 000000000..3543acb15 --- /dev/null +++ b/sdkproject/Assets/Resources.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6c7f7345a2ce049d9b39d8ee2f388854 +folderAsset: yes +timeCreated: 1522933685 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/StreamingAssets.meta b/sdkproject/Assets/StreamingAssets.meta new file mode 100644 index 000000000..d04283834 --- /dev/null +++ b/sdkproject/Assets/StreamingAssets.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7ad5bb5010449443388dd2ce544bad0a +folderAsset: yes +timeCreated: 1524161041 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/StreamingAssets/build_info.txt.meta b/sdkproject/Assets/StreamingAssets/build_info.txt.meta new file mode 100644 index 000000000..3f9f612c1 --- /dev/null +++ b/sdkproject/Assets/StreamingAssets/build_info.txt.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1bb0ecaed5b8841b0bfb500b045609d7 +timeCreated: 1522712544 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From d6acdc58d8db680feb7c237ce7b68822cca96e88 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Wed, 25 Apr 2018 15:55:40 -0700 Subject: [PATCH 02/21] removed datatype... cleaned the class for ease of use in the future --- .../Unity/DataContainers/MapboxEnums.cs | 9 --- .../Mapbox/Unity/Editor/EditorTileJSONData.cs | 21 ++--- .../Mapbox/Unity/Editor/LayerEditorPopUp.cs | 52 ++++++++++++ .../Mapbox/Unity/Editor/MapManagerEditor.cs | 81 +++++++++++-------- 4 files changed, 113 insertions(+), 50 deletions(-) create mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/MapboxEnums.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/MapboxEnums.cs index 0043677c9..e35685c45 100644 --- a/sdkproject/Assets/Mapbox/Unity/DataContainers/MapboxEnums.cs +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/MapboxEnums.cs @@ -176,13 +176,4 @@ public enum ColliderType [Description("Sphere collider added to the GameObject.")] SphereCollider, } - - /// - /// Data type for the property name derived from the Mapbox tilset layer - /// - public enum PropertyDataType - { - String, - Number - } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs index 8bb2bfde2..eef34aed5 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs @@ -14,17 +14,17 @@ public static EditorTileJSONData Instance{ return _instance; } } + public readonly string commonLayersKey = "Common layers across all sources"; - public bool tileJSONLoaded = false; /// - /// List of data sources (tileset ids) linked to a layer name + /// This boolean is to check if tile JSON data has loaded after the data source has changed /// - public Dictionary> LayerPropertyDictionary = new Dictionary>(); + public bool tileJSONLoaded = false; /// /// The description of the property in a layer /// - public Dictionary PropertyDescriptionDictionary = new Dictionary(); + public Dictionary> LayerPropertyDescriptionDictionary = new Dictionary>(); /// /// List of data sources (tileset ids) linked to a layer name @@ -32,12 +32,15 @@ public static EditorTileJSONData Instance{ public Dictionary> LayerSourcesDictionary = new Dictionary>(); /// - /// The source layers in a dictionary + /// Dictionary containting the list of layers in a source /// public Dictionary> SourceLayersDictionary = new Dictionary>(); - /// - /// The data type of the property name in the layer - /// - public Dictionary PropertyDataTypeDictionary = new Dictionary(); + public void ClearData() + { + tileJSONLoaded = false; + LayerPropertyDescriptionDictionary = new Dictionary>(); + LayerSourcesDictionary = new Dictionary>(); + SourceLayersDictionary = new Dictionary>(); + } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs b/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs new file mode 100644 index 000000000..4c9dca4c9 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs @@ -0,0 +1,52 @@ +using UnityEngine; +using UnityEditor; + +public class LayerEditorPopUp : PopupWindowContent +{ + bool toggle1 = true; + bool toggle2 = true; + bool toggle3 = true; + + public override Vector2 GetWindowSize() + { + return new Vector2(200, 150); + } + + public override void OnGUI(Rect rect) + { + EditorTileJSONData data = EditorTileJSONData.Instance; + if(!data.tileJSONLoaded) + { + EditorGUILayout.LabelField("Loading . . ."); + } + else + { + foreach(var item in data.LayerSourcesDictionary) + { + if(item.Value.Count>1) // more than one source has the layer + { + EditorGUILayout.LabelField("Shared sources", EditorStyles.boldLabel); + EditorGUI.indentLevel++; + EditorGUILayout.SelectableLabel(item.Key); + EditorGUI.indentLevel--; + } + else + { + EditorGUI.indentLevel++; + EditorGUILayout.SelectableLabel(item.Key); + EditorGUI.indentLevel--; + } + } + } + } + + public override void OnOpen() + { + Debug.Log("Popup opened: " + this); + } + + public override void OnClose() + { + Debug.Log("Popup closed: " + this); + } +} \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 00b6cf160..8eefb3009 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -345,23 +345,16 @@ void PresetARWorldScale(SerializedProperty unifiedMap) } - private PropertyDataType GetPropertyDataType(string propertyDescription) - { - if (propertyDescription.ToLower().Contains("number")) - return PropertyDataType.Number; - - return PropertyDataType.String; - } - private void ProcessTileJSONData(TileJSONResponse tjr) { TileJSONResponse response = tjr; EditorTileJSONData tileJSONData = EditorTileJSONData.Instance; + tileJSONData.ClearData(); List layerPropertiesList = new List(); List sourceLayersList = new List(); - if (response.VectorLayers == null && response.VectorLayers.Length == 0) + if (response==null || response.VectorLayers == null || response.VectorLayers.Length == 0) { return; } @@ -369,7 +362,6 @@ private void ProcessTileJSONData(TileJSONResponse tjr) var propertyName = ""; var propertyDescription = ""; var layerSource = ""; - PropertyDataType propertyDataType = PropertyDataType.Number; foreach (var layer in response.VectorLayers) { @@ -377,34 +369,31 @@ private void ProcessTileJSONData(TileJSONResponse tjr) layerPropertiesList = new List(); layerSource = layer.Source; + if (layer.Fields.Count == 0) + continue; + foreach (var property in layer.Fields) { propertyName = property.Key; propertyDescription = property.Value; - propertyDataType = GetPropertyDataType(propertyDescription); layerPropertiesList.Add(propertyName); - //adding data type for the property to the dictionary - if (tileJSONData.PropertyDataTypeDictionary.ContainsKey(propertyName)) - tileJSONData.PropertyDataTypeDictionary[propertyName] = propertyDataType; - else - tileJSONData.PropertyDataTypeDictionary.Add(propertyName, propertyDataType); - //adding property descriptions - if (tileJSONData.PropertyDescriptionDictionary.ContainsKey(propertyName)) - tileJSONData.PropertyDescriptionDictionary[propertyName] = propertyDescription; + if (tileJSONData.LayerPropertyDescriptionDictionary.ContainsKey(layerName)) + { + if (tileJSONData.LayerPropertyDescriptionDictionary[layerName].ContainsKey(propertyName)) + { + tileJSONData.LayerPropertyDescriptionDictionary[layerName][propertyName] = propertyDescription; + } + else + { + tileJSONData.LayerPropertyDescriptionDictionary[layerName].Add(propertyName, propertyDescription); + } + } else - tileJSONData.PropertyDescriptionDictionary.Add(propertyName, propertyDescription); - } - - //loading layerproperty dictionary - if (tileJSONData.LayerPropertyDictionary.ContainsKey(layerName)) - { - tileJSONData.LayerPropertyDictionary[layerName].AddRange(layerPropertiesList); - } - else - { - tileJSONData.LayerPropertyDictionary.Add(layerName, layerPropertiesList); + { + tileJSONData.LayerPropertyDescriptionDictionary.Add(layerName, new Dictionary() { { propertyName, propertyDescription } }); + } } //loading layer sources @@ -420,7 +409,35 @@ private void ProcessTileJSONData(TileJSONResponse tjr) //loading layers to a data source if (tileJSONData.SourceLayersDictionary.ContainsKey(layerSource)) { - tileJSONData.SourceLayersDictionary[layerSource].Add(layerName); + string commonLayersKey = tileJSONData.commonLayersKey; + List sourceList = new List(); + tileJSONData.LayerSourcesDictionary.TryGetValue(layerName, out sourceList); + + if (sourceList.Count > 1 && sourceList.Contains(layerSource)) // the current layerName has more than one source + { + if (tileJSONData.SourceLayersDictionary.ContainsKey(commonLayersKey)) + { + tileJSONData.SourceLayersDictionary[commonLayersKey].Add(layerName); + } + else + { + tileJSONData.SourceLayersDictionary.Add(commonLayersKey, new List() { layerName }); + } + + //remove the layer from other different sources + foreach (var source in sourceList) + { + tileJSONData.SourceLayersDictionary[source].Remove(layerName); + + //if the source contains zero layers remove th source from the list + if (tileJSONData.SourceLayersDictionary[source].Count == 0) + tileJSONData.SourceLayersDictionary.Remove(source); + } + } + else + { + tileJSONData.SourceLayersDictionary[layerSource].Add(layerName); + } } else { @@ -429,7 +446,7 @@ private void ProcessTileJSONData(TileJSONResponse tjr) } tileJSONData.tileJSONLoaded = true; - //Debug.Log(tileJSONResponse); + Debug.Log(tileJSONData); } } } From 57a35b17a73185fd0777a8dd3d96d4f73f9a0d22 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Thu, 26 Apr 2018 21:54:33 -0700 Subject: [PATCH 03/21] new architecture works --- sdkproject/Assets/Mapbox/Prefabs/Map.prefab | 7 +- .../GeometryExtrusionOptions.cs | 5 + .../Unity/DataContainers/TileJsonData.cs | 193 ++++++++++++++++++ .../TileJsonData.cs.meta} | 4 +- .../Mapbox/Unity/Editor/EditorTileJSONData.cs | 46 ----- .../Mapbox/Unity/Editor/LayerEditorPopUp.cs | 52 ----- .../Unity/Editor/LayerEditorPopUp.cs.meta | 13 -- .../Mapbox/Unity/Editor/MapManagerEditor.cs | 143 +------------ .../CoreVectorLayerPropertiesDrawer.cs | 16 +- .../GeometryExtrusionOptionsDrawer.cs | 33 ++- .../VectorLayerPropertiesDrawer.cs | 47 ++++- .../CoreVectorLayerProperties.cs | 2 + .../ProjectSettings/EditorBuildSettings.asset | 6 +- sdkproject/ProjectSettings/ProjectVersion.txt | 2 +- 14 files changed, 301 insertions(+), 268 deletions(-) create mode 100644 sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs rename sdkproject/Assets/Mapbox/Unity/{Editor/EditorTileJSONData.cs.meta => DataContainers/TileJsonData.cs.meta} (77%) delete mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs delete mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs delete mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs.meta diff --git a/sdkproject/Assets/Mapbox/Prefabs/Map.prefab b/sdkproject/Assets/Mapbox/Prefabs/Map.prefab index d3e7310c2..1aafb0c49 100644 --- a/sdkproject/Assets/Mapbox/Prefabs/Map.prefab +++ b/sdkproject/Assets/Mapbox/Prefabs/Map.prefab @@ -51,6 +51,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: cd961b1c9541a4cee99686069ecce852, type: 3} m_Name: m_EditorClassIdentifier: + _initializeOnStart: 1 _options: locationOptions: latitudeLongitude: 37.784179, -122.401583 @@ -120,12 +121,12 @@ MonoBehaviour: wallMaterial: {fileID: 0} _vectorData: _layerProperty: - sourceType: 3 + sourceType: 1 sourceOptions: - isActive: 0 + isActive: 1 layerSource: Name: Mapbox Terrain - Id: mapbox.3d-buildings,mapbox.mapbox-streets-v7 + Id: mapbox.mapbox-streets-v7 Modified: UserName: useOptimizedStyle: 0 diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryExtrusionOptions.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryExtrusionOptions.cs index 71189adae..642b8641f 100644 --- a/sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryExtrusionOptions.cs +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryExtrusionOptions.cs @@ -15,6 +15,11 @@ public override Type ModifierType return typeof(HeightModifier); } } + + [SerializeField] + private TileJsonData _tileJsonData; + [SerializeField] + private string _selectedLayerName = ""; public ExtrusionType extrusionType = ExtrusionType.None; public ExtrusionGeometryType extrusionGeometryType = ExtrusionGeometryType.RoofAndSide; [Tooltip("Property name in feature layer to use for extrusion.")] diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs new file mode 100644 index 000000000..6b91fcd17 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs @@ -0,0 +1,193 @@ +namespace Mapbox.Unity.Map +{ + using System; + using System.Collections.Generic; + using Mapbox.Platform.TilesetTileJSON; + using UnityEngine; + + public class TileJsonData : ScriptableObject + { + public readonly string commonLayersKey = "(common across all sources)"; + public readonly string optionalPropertiesString = "(may not appear)"; + /// + /// This boolean is to check if tile JSON data has loaded after the data source has changed + /// + public bool tileJSONLoaded = false; + /// + /// Layer Display Names seen in the editor + /// + public List LayerDisplayNames = new List(); + + + /// + /// Property Display Names seen in the editor + /// + public Dictionary> PropertyDisplayNames = new Dictionary>(); + + /// + /// The description of the property in a layer + /// + public Dictionary> LayerPropertyDescriptionDictionary = new Dictionary>(); + + /// + /// List of data sources (tileset ids) linked to a layer name + /// + public Dictionary> LayerSourcesDictionary = new Dictionary>(); + + /// + /// Dictionary containting the list of layers in a source + /// + public Dictionary> SourceLayersDictionary = new Dictionary>(); + + public void ClearData() + { + tileJSONLoaded = false; + LayerPropertyDescriptionDictionary.Clear(); + LayerSourcesDictionary.Clear(); + SourceLayersDictionary.Clear(); + LayerDisplayNames.Clear(); + PropertyDisplayNames.Clear(); + } + + public void ProcessTileJSONData(TileJSONResponse tjr) + { + TileJSONResponse response = tjr; + + List layerPropertiesList = new List(); + List sourceLayersList = new List(); + + if (response == null || response.VectorLayers == null || response.VectorLayers.Length == 0) + { + return; + } + + ClearData(); + + var propertyName = ""; + var propertyDescription = ""; + var layerSource = ""; + + foreach (var layer in response.VectorLayers) + { + //load layer names + var layerName = layer.Id; + layerPropertiesList = new List(); + layerSource = layer.Source; + if (layer.Fields.Count == 0) + continue; + + //loading layer sources + if (LayerSourcesDictionary.ContainsKey(layerName)) + { + LayerSourcesDictionary[layerName].Add(layerSource); + } + else + { + LayerSourcesDictionary.Add(layerName, new List() { layerSource }); + } + + //loading layers to a data source + if (SourceLayersDictionary.ContainsKey(layerSource)) + { + List sourceList = new List(); + LayerSourcesDictionary.TryGetValue(layerName, out sourceList); + + if (sourceList.Count > 1 && sourceList.Contains(layerSource)) // the current layerName has more than one source + { + if (SourceLayersDictionary.ContainsKey(commonLayersKey)) + { + SourceLayersDictionary[commonLayersKey].Add(layerName); + if (LayerDisplayNames.Contains(layerName)) + { + LayerDisplayNames.Remove(layerName); + } + LayerDisplayNames.Add(layerName + " " + commonLayersKey); + } + else + { + SourceLayersDictionary.Add(commonLayersKey, new List() { layerName }); + if (LayerDisplayNames.Contains(layerName)) + { + LayerDisplayNames.Remove(layerName); + } + LayerDisplayNames.Add(layerName + " " + commonLayersKey); + } + + //remove the layer from other different sources + //foreach (var source in sourceList) + //{ + // SourceLayersDictionary[source].Remove(layerName); + + // //if the source contains zero layers remove th source from the list + // if (SourceLayersDictionary[source].Count == 0) + // SourceLayersDictionary.Remove(source); + //} + } + else + { + SourceLayersDictionary[layerSource].Add(layerName); + LayerDisplayNames.Add(layerName); + } + } + else + { + SourceLayersDictionary.Add(layerSource, new List() { layerName }); + LayerDisplayNames.Add(layerName); + } + + + //Load properties + foreach (var property in layer.Fields) + { + propertyName = property.Key; + propertyDescription = property.Value; + layerPropertiesList.Add(propertyName); + + //adding property descriptions + if (LayerPropertyDescriptionDictionary.ContainsKey(layerName)) + { + if (!LayerPropertyDescriptionDictionary[layerName].ContainsKey(propertyName)) + { + LayerPropertyDescriptionDictionary[layerName].Add(propertyName, propertyDescription); + } + } + else + { + LayerPropertyDescriptionDictionary.Add(layerName, new Dictionary() { { propertyName, propertyDescription } }); + } + + //Loading display names for properties + if (PropertyDisplayNames.ContainsKey(layerName)) + { + if (!PropertyDisplayNames[layerName].Contains(propertyName)) + { + PropertyDisplayNames[layerName].Add(propertyName); + + //logic to add the list of masked properties from all sources that are not #1 + if (layerName == "building") + if (LayerSourcesDictionary[layerName].Count > 1) + { + var firstSource = tjr.Source.Split(new string[] { "," }, System.StringSplitOptions.None)[0].Trim(); + if (layerSource != firstSource) + { + if (PropertyDisplayNames[layerName].Contains(propertyName)) + { + PropertyDisplayNames[layerName].Remove(propertyName); + } + + PropertyDisplayNames[layerName].Add(propertyName + " " + optionalPropertiesString); + } + } + } + } + else + { + PropertyDisplayNames.Add(layerName, new List { propertyName }); + } + } + } + + tileJSONLoaded = true; + } + } +} \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs.meta b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs.meta similarity index 77% rename from sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs.meta rename to sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs.meta index 93f374770..2d8b785ff 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs.meta +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 14acf9704f4dd49468b22be126789dd4 -timeCreated: 1524616475 +guid: 52cf051b4afa24ba6895b9a42b179eed +timeCreated: 1524801966 licenseType: Pro MonoImporter: externalObjects: {} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs deleted file mode 100644 index eef34aed5..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJSONData.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; -using Mapbox.Unity.Map; - -public class EditorTileJSONData -{ - - private static EditorTileJSONData _instance; - public static EditorTileJSONData Instance{ - get - { - if (_instance == null) - _instance = new EditorTileJSONData(); - - return _instance; - } - } - public readonly string commonLayersKey = "Common layers across all sources"; - - /// - /// This boolean is to check if tile JSON data has loaded after the data source has changed - /// - public bool tileJSONLoaded = false; - - /// - /// The description of the property in a layer - /// - public Dictionary> LayerPropertyDescriptionDictionary = new Dictionary>(); - - /// - /// List of data sources (tileset ids) linked to a layer name - /// - public Dictionary> LayerSourcesDictionary = new Dictionary>(); - - /// - /// Dictionary containting the list of layers in a source - /// - public Dictionary> SourceLayersDictionary = new Dictionary>(); - - public void ClearData() - { - tileJSONLoaded = false; - LayerPropertyDescriptionDictionary = new Dictionary>(); - LayerSourcesDictionary = new Dictionary>(); - SourceLayersDictionary = new Dictionary>(); - } -} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs b/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs deleted file mode 100644 index 4c9dca4c9..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs +++ /dev/null @@ -1,52 +0,0 @@ -using UnityEngine; -using UnityEditor; - -public class LayerEditorPopUp : PopupWindowContent -{ - bool toggle1 = true; - bool toggle2 = true; - bool toggle3 = true; - - public override Vector2 GetWindowSize() - { - return new Vector2(200, 150); - } - - public override void OnGUI(Rect rect) - { - EditorTileJSONData data = EditorTileJSONData.Instance; - if(!data.tileJSONLoaded) - { - EditorGUILayout.LabelField("Loading . . ."); - } - else - { - foreach(var item in data.LayerSourcesDictionary) - { - if(item.Value.Count>1) // more than one source has the layer - { - EditorGUILayout.LabelField("Shared sources", EditorStyles.boldLabel); - EditorGUI.indentLevel++; - EditorGUILayout.SelectableLabel(item.Key); - EditorGUI.indentLevel--; - } - else - { - EditorGUI.indentLevel++; - EditorGUILayout.SelectableLabel(item.Key); - EditorGUI.indentLevel--; - } - } - } - } - - public override void OnOpen() - { - Debug.Log("Popup opened: " + this); - } - - public override void OnClose() - { - Debug.Log("Popup closed: " + this); - } -} \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs.meta b/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs.meta deleted file mode 100644 index 8f5d79234..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/LayerEditorPopUp.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: a57a268b7a7d648928c839acc8c96981 -timeCreated: 1524618245 -licenseType: Pro -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 8eefb3009..229db5ab7 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -10,24 +10,6 @@ [CanEditMultipleObjects] public class MapManagerEditor : Editor { - private Rect buttonRect; - /// - /// Gets or sets the layerID - /// - /// true then show general section; otherwise hide, false. - private string TilesetId - { - get - { - return EditorPrefs.GetString("MapManagerEditor_tilesetId"); - } - set - { - EditorPrefs.SetString("MapManagerEditor_tilesetId", value); - } - } - - /// /// Gets or sets a value indicating whether to show general section . /// @@ -181,26 +163,7 @@ public override void OnInspectorGUI() ShowVector = EditorGUILayout.Foldout(ShowVector, "VECTOR"); if (ShowVector) { - var vectorDataProperty = serializedObject.FindProperty("_vectorData"); - - - var layerProperty = vectorDataProperty.FindPropertyRelative("_layerProperty"); - var layerSourceProperty = layerProperty.FindPropertyRelative("sourceOptions"); - var sourceType = layerProperty.FindPropertyRelative("sourceType"); - VectorSourceType sourceTypeValue = (VectorSourceType)sourceType.enumValueIndex; - string layerString = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id").stringValue; - - if (sourceTypeValue != VectorSourceType.None && !string.IsNullOrEmpty(layerString)) - { - if (string.IsNullOrEmpty(TilesetId) || layerString != TilesetId) - { - EditorTileJSONData tileJSONData = EditorTileJSONData.Instance; - tileJSONData.tileJSONLoaded = false; - TilesetId = layerString; - Unity.MapboxAccess.Instance.TileJSON.Get(layerString,ProcessTileJSONData); - } - } - ShowSection(vectorDataProperty, "_layerProperty"); + ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); } GUILayout.EndVertical(); @@ -344,109 +307,5 @@ void PresetARWorldScale(SerializedProperty unifiedMap) vectorSourceType.enumValueIndex = (int)VectorSourceType.MapboxStreets; } - - private void ProcessTileJSONData(TileJSONResponse tjr) - { - TileJSONResponse response = tjr; - EditorTileJSONData tileJSONData = EditorTileJSONData.Instance; - tileJSONData.ClearData(); - - List layerPropertiesList = new List(); - List sourceLayersList = new List(); - - if (response==null || response.VectorLayers == null || response.VectorLayers.Length == 0) - { - return; - } - - var propertyName = ""; - var propertyDescription = ""; - var layerSource = ""; - - foreach (var layer in response.VectorLayers) - { - var layerName = layer.Id; - layerPropertiesList = new List(); - layerSource = layer.Source; - - if (layer.Fields.Count == 0) - continue; - - foreach (var property in layer.Fields) - { - propertyName = property.Key; - propertyDescription = property.Value; - layerPropertiesList.Add(propertyName); - - //adding property descriptions - if (tileJSONData.LayerPropertyDescriptionDictionary.ContainsKey(layerName)) - { - if (tileJSONData.LayerPropertyDescriptionDictionary[layerName].ContainsKey(propertyName)) - { - tileJSONData.LayerPropertyDescriptionDictionary[layerName][propertyName] = propertyDescription; - } - else - { - tileJSONData.LayerPropertyDescriptionDictionary[layerName].Add(propertyName, propertyDescription); - } - } - else - { - tileJSONData.LayerPropertyDescriptionDictionary.Add(layerName, new Dictionary() { { propertyName, propertyDescription } }); - } - } - - //loading layer sources - if (tileJSONData.LayerSourcesDictionary.ContainsKey(layerName)) - { - tileJSONData.LayerSourcesDictionary[layerName].Add(layerSource); - } - else - { - tileJSONData.LayerSourcesDictionary.Add(layerName, new List() { layerSource }); - } - - //loading layers to a data source - if (tileJSONData.SourceLayersDictionary.ContainsKey(layerSource)) - { - string commonLayersKey = tileJSONData.commonLayersKey; - List sourceList = new List(); - tileJSONData.LayerSourcesDictionary.TryGetValue(layerName, out sourceList); - - if (sourceList.Count > 1 && sourceList.Contains(layerSource)) // the current layerName has more than one source - { - if (tileJSONData.SourceLayersDictionary.ContainsKey(commonLayersKey)) - { - tileJSONData.SourceLayersDictionary[commonLayersKey].Add(layerName); - } - else - { - tileJSONData.SourceLayersDictionary.Add(commonLayersKey, new List() { layerName }); - } - - //remove the layer from other different sources - foreach (var source in sourceList) - { - tileJSONData.SourceLayersDictionary[source].Remove(layerName); - - //if the source contains zero layers remove th source from the list - if (tileJSONData.SourceLayersDictionary[source].Count == 0) - tileJSONData.SourceLayersDictionary.Remove(source); - } - } - else - { - tileJSONData.SourceLayersDictionary[layerSource].Add(layerName); - } - } - else - { - tileJSONData.SourceLayersDictionary.Add(layerSource, new List() { layerName }); - } - } - - tileJSONData.tileJSONLoaded = true; - Debug.Log(tileJSONData); - } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index 67a69bab2..037da49c2 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -3,10 +3,12 @@ using UnityEditor; using UnityEngine; using Mapbox.Unity.Map; + using System.Collections.Generic; [CustomPropertyDrawer(typeof(CoreVectorLayerProperties))] public class CoreVectorLayerPropertiesDrawer : PropertyDrawer { + private int index = 0; static float lineHeight = EditorGUIUtility.singleLineHeight; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) @@ -25,7 +27,19 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.indentLevel++; position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("layerName")); + //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("layerName")); + TileJsonData tileJSONData = property.FindPropertyRelative("_tileJsonData").objectReferenceValue as TileJsonData; + if (tileJSONData.LayerDisplayNames.Count > 0) + { + var layerDisplayNames = tileJSONData.LayerDisplayNames; + var layerNamesArray = layerDisplayNames.ToArray(); + typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Layer Name", tooltip = "The layer name from the Mapbox tileset that would be used for visualizing a feature" }); + EditorGUI.indentLevel--; + index = EditorGUI.Popup(typePosition, index, layerNamesArray); + var parsedString = layerNamesArray[index].Split(new string[] { tileJSONData.commonLayersKey }, System.StringSplitOptions.None)[0].Trim(); + property.FindPropertyRelative("layerName").stringValue = parsedString; + EditorGUI.indentLevel++; + } position.y += lineHeight; EditorGUI.PropertyField(position, property.FindPropertyRelative("snapToTerrain")); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index a8097f9b2..0d70026c7 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -8,6 +8,7 @@ [CustomPropertyDrawer(typeof(GeometryExtrusionOptions))] public class GeometryExtrusionOptionsDrawer : PropertyDrawer { + private int index = 0; static float lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] sourceTypeContent; bool isGUIContentSet = false; @@ -55,25 +56,29 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + DrawPropertyDropDown(property, position); break; case Unity.Map.ExtrusionType.MinHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + DrawPropertyDropDown(property, position); break; case Unity.Map.ExtrusionType.MaxHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + DrawPropertyDropDown(property, position); break; case Unity.Map.ExtrusionType.RangeHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + DrawPropertyDropDown(property, position); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), minHeightProperty); position.y += lineHeight; @@ -99,6 +104,26 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.EndProperty(); } + + private void DrawPropertyDropDown(SerializedProperty property, Rect position) + { + var selectedLayerName = property.FindPropertyRelative("_selectedLayerName").stringValue; + + if (string.IsNullOrEmpty(selectedLayerName)) + return; + + TileJsonData tileJsonData = property.FindPropertyRelative("_tileJsonData").objectReferenceValue as TileJsonData; + var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName]; + var propertyNamesArray = propertyDisplayNames.ToArray(); + Rect typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" }); + EditorGUI.indentLevel -= 2; + index = EditorGUI.Popup(typePosition, index, propertyNamesArray); + var parsedString = propertyNamesArray[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); + property.FindPropertyRelative("propertyName").stringValue = parsedString; + EditorGUI.indentLevel += 2; + + } + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { var extrusionTypeProperty = property.FindPropertyRelative("extrusionType"); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index d143f19fb..3c08e3aed 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -14,9 +14,27 @@ [CustomPropertyDrawer(typeof(VectorLayerProperties))] public class VectorLayerPropertiesDrawer : PropertyDrawer { + private TileJsonData _tileJsonData; static float _lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] _sourceTypeContent; bool _isGUIContentSet = false; + private TileJsonData tileJSONData; + + /// + /// Gets or sets the layerID + /// + /// true then show general section; otherwise hide, false. + private string TilesetId + { + get + { + return EditorPrefs.GetString("MapManagerEditor_tilesetId"); + } + set + { + EditorPrefs.SetString("MapManagerEditor_tilesetId", value); + } + } bool ShowPosition { @@ -116,12 +134,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); + LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); GUI.enabled = true; isActiveProperty.boolValue = true; break; case VectorSourceType.Custom: layerSourceId.stringValue = CustomSourceMapId; EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); + LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); CustomSourceMapId = layerSourceId.stringValue; isActiveProperty.boolValue = true; break; @@ -249,15 +269,22 @@ void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProper GUILayout.BeginVertical(); var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); + subLayerCoreOptions.FindPropertyRelative("_tileJsonData").objectReferenceValue = tileJSONData; + VectorPrimitiveType primitiveTypeProp = (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex; EditorGUILayout.PropertyField(subLayerCoreOptions); + var extrusionOptions = layerProperty.FindPropertyRelative("extrusionOptions"); + extrusionOptions.FindPropertyRelative("_tileJsonData").objectReferenceValue = tileJSONData ; + //loading up the selectedLayerName for extrusion options to pull up the right propertyName + extrusionOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue; + if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom) { EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("colliderOptions")); - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("extrusionOptions")); + EditorGUILayout.PropertyField(extrusionOptions); EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions")); } @@ -384,5 +411,23 @@ void DrawModifiers(SerializedProperty property, GUIContent label) // EditorGUILayout.EndVertical(); } + + private void LoadEditorTileJSON(VectorSourceType sourceTypeValue, string sourceString) + { + if (sourceTypeValue != VectorSourceType.None && !string.IsNullOrEmpty(sourceString)) + { + if (string.IsNullOrEmpty(TilesetId) || sourceString != TilesetId) + { + TilesetId = sourceString; + tileJSONData = ScriptableObject.CreateInstance(); + tileJSONData.ClearData(); + Unity.MapboxAccess.Instance.TileJSON.Get(sourceString, tileJSONData.ProcessTileJSONData); + } + } + else + { + tileJSONData.ClearData(); + } + } } } diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs b/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs index 1989ec5b8..c3dbe8a15 100644 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs +++ b/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs @@ -8,6 +8,8 @@ [Serializable] public class CoreVectorLayerProperties { + [SerializeField] + private TileJsonData _tileJsonData; [Tooltip("Is visualizer active.")] public bool isActive = true; [Tooltip("Name of the visualizer. ")] diff --git a/sdkproject/ProjectSettings/EditorBuildSettings.asset b/sdkproject/ProjectSettings/EditorBuildSettings.asset index 833b6ebb0..48a680a58 100644 --- a/sdkproject/ProjectSettings/EditorBuildSettings.asset +++ b/sdkproject/ProjectSettings/EditorBuildSettings.asset @@ -5,9 +5,9 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 m_Scenes: - - enabled: 1 - path: Assets/Mapbox/Main.unity - guid: 643bfa26e0eed440db629d1f4fc9f6ed + - enabled: 0 + path: + guid: 00000000000000000000000000000000 - enabled: 1 path: Assets/Mapbox/Examples/0_PrefabScenes/CitySimulator.unity guid: d24dbd32aba234c98826e2c59ebfdf84 diff --git a/sdkproject/ProjectSettings/ProjectVersion.txt b/sdkproject/ProjectSettings/ProjectVersion.txt index 27997c5a0..ac7d21464 100644 --- a/sdkproject/ProjectSettings/ProjectVersion.txt +++ b/sdkproject/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2017.3.1f1 +m_EditorVersion: 2017.4.0f1 From bf56527c5dddcac21c51688d99ce3e3e5c5d5d02 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 27 Apr 2018 16:59:39 -0700 Subject: [PATCH 04/21] wip --- .../Unity/DataContainers/TileJsonData.cs | 7 +++--- .../GeometryExtrusionOptionsDrawer.cs | 23 ++++++++++++++++--- .../VectorLayerPropertiesDrawer.cs | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs index 6b91fcd17..201488bfa 100644 --- a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs @@ -7,8 +7,8 @@ public class TileJsonData : ScriptableObject { - public readonly string commonLayersKey = "(common across all sources)"; - public readonly string optionalPropertiesString = "(may not appear)"; + public readonly string commonLayersKey = "(layer found in more than one source)"; + public readonly string optionalPropertiesString = "(may not appear across all locations)"; /// /// This boolean is to check if tile JSON data has loaded after the data source has changed /// @@ -164,8 +164,7 @@ public void ProcessTileJSONData(TileJSONResponse tjr) PropertyDisplayNames[layerName].Add(propertyName); //logic to add the list of masked properties from all sources that are not #1 - if (layerName == "building") - if (LayerSourcesDictionary[layerName].Count > 1) + if (LayerSourcesDictionary[layerName].Count > 1 && !string.IsNullOrEmpty(tjr.Source)) { var firstSource = tjr.Source.Split(new string[] { "," }, System.StringSplitOptions.None)[0].Trim(); if (layerSource != firstSource) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index 0d70026c7..00f60cf08 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -4,11 +4,13 @@ using UnityEngine; using Mapbox.Unity.Map; using Mapbox.VectorTile.ExtensionMethods; + using System.Linq; [CustomPropertyDrawer(typeof(GeometryExtrusionOptions))] public class GeometryExtrusionOptionsDrawer : PropertyDrawer { private int index = 0; + private string[] propertyNamesArray; static float lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] sourceTypeContent; bool isGUIContentSet = false; @@ -58,6 +60,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); + position.y += 3*lineHeight; break; case Unity.Map.ExtrusionType.MinHeight: position.y += lineHeight; @@ -113,14 +116,28 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) return; TileJsonData tileJsonData = property.FindPropertyRelative("_tileJsonData").objectReferenceValue as TileJsonData; + if (!tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName)) + return; var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName]; - var propertyNamesArray = propertyDisplayNames.ToArray(); + + if (propertyNamesArray != null && !Enumerable.SequenceEqual(propertyNamesArray, propertyDisplayNames.ToArray())) + index = 0; + + propertyNamesArray = propertyDisplayNames.ToArray(); Rect typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" }); EditorGUI.indentLevel -= 2; index = EditorGUI.Popup(typePosition, index, propertyNamesArray); + var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][propertyNamesArray[index]]; + position.y += lineHeight; var parsedString = propertyNamesArray[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); property.FindPropertyRelative("propertyName").stringValue = parsedString; EditorGUI.indentLevel += 2; + typePosition.y += lineHeight; + typePosition.height = 2 * lineHeight; + EditorGUI.HelpBox(typePosition,descriptionString, MessageType.Info); + + + } @@ -140,10 +157,10 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent case Unity.Map.ExtrusionType.PropertyHeight: case Unity.Map.ExtrusionType.MinHeight: case Unity.Map.ExtrusionType.MaxHeight: - rows += 3; + rows += 5; break; case Unity.Map.ExtrusionType.RangeHeight: - rows += 5; + rows += 7; break; case Unity.Map.ExtrusionType.AbsoluteHeight: rows += 3; diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 3c08e3aed..c0925d9cc 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -420,7 +420,7 @@ private void LoadEditorTileJSON(VectorSourceType sourceTypeValue, string sourceS { TilesetId = sourceString; tileJSONData = ScriptableObject.CreateInstance(); - tileJSONData.ClearData(); + //tileJSONData.ClearData(); Unity.MapboxAccess.Instance.TileJSON.Get(sourceString, tileJSONData.ProcessTileJSONData); } } From 3d6551d8376ff055ce7a51b8c42f302dbe7f219a Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 27 Apr 2018 18:49:45 -0700 Subject: [PATCH 05/21] all visible features in for now.. --- .../GeometryExtrusionOptionsDrawer.cs | 19 +++++---- .../VectorFilterOptionsDrawer.cs | 41 +++++++++++++++++-- .../VectorLayerPropertiesDrawer.cs | 6 ++- .../CoreVectorLayerProperties.cs | 4 ++ 4 files changed, 57 insertions(+), 13 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index 00f60cf08..a4d6ee535 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -60,7 +60,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); - position.y += 3*lineHeight; + position.y += 2.5f *lineHeight; break; case Unity.Map.ExtrusionType.MinHeight: position.y += lineHeight; @@ -68,6 +68,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); + position.y += 2.5f * lineHeight; break; case Unity.Map.ExtrusionType.MaxHeight: position.y += lineHeight; @@ -75,6 +76,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); + position.y += 2.5f * lineHeight; break; case Unity.Map.ExtrusionType.RangeHeight: position.y += lineHeight; @@ -82,6 +84,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); + position.y += 2.5f * lineHeight; position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), minHeightProperty); position.y += lineHeight; @@ -127,18 +130,16 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) Rect typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" }); EditorGUI.indentLevel -= 2; index = EditorGUI.Popup(typePosition, index, propertyNamesArray); - var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][propertyNamesArray[index]]; position.y += lineHeight; var parsedString = propertyNamesArray[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); property.FindPropertyRelative("propertyName").stringValue = parsedString; EditorGUI.indentLevel += 2; + + var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][propertyNamesArray[index]]; typePosition.y += lineHeight; - typePosition.height = 2 * lineHeight; + typePosition.height = (float)(2.5f * lineHeight); + EditorGUI.PrefixLabel(new Rect(position.x, typePosition.y + lineHeight/2, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Property Description", tooltip = "Factual information about the selected property" }); EditorGUI.HelpBox(typePosition,descriptionString, MessageType.Info); - - - - } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) @@ -157,10 +158,10 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent case Unity.Map.ExtrusionType.PropertyHeight: case Unity.Map.ExtrusionType.MinHeight: case Unity.Map.ExtrusionType.MaxHeight: - rows += 5; + rows += 6; break; case Unity.Map.ExtrusionType.RangeHeight: - rows += 7; + rows += 8; break; case Unity.Map.ExtrusionType.AbsoluteHeight: rows += 3; diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs index 9fd17eb6e..bc341bfa3 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs @@ -4,10 +4,14 @@ using UnityEngine; using Mapbox.Unity.Map; using Mapbox.Unity.MeshGeneration.Filters; + using System.Linq; [CustomPropertyDrawer(typeof(VectorFilterOptions))] public class VectorFilterOptionsDrawer : PropertyDrawer { + private int index = 0; + private string[] propertyNamesArray; + private string[] descriptionArray; static float lineHeight = EditorGUIUtility.singleLineHeight; bool showFilters = true; @@ -29,7 +33,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten for (int i = 0; i < propertyFilters.arraySize; i++) { - DrawLayerFilter(propertyFilters, i); + DrawLayerFilter(property, propertyFilters, i); } if (propertyFilters.arraySize > 0) { @@ -54,7 +58,7 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent return lineHeight; } - void DrawLayerFilter(SerializedProperty propertyFilters, int index) + void DrawLayerFilter(SerializedProperty originalProperty, SerializedProperty propertyFilters, int index) { var property = propertyFilters.GetArrayElementAtIndex(index); var filterOperatorProp = property.FindPropertyRelative("filterOperator"); @@ -91,7 +95,8 @@ void DrawLayerFilter(SerializedProperty propertyFilters, int index) EditorGUILayout.BeginHorizontal(); - property.FindPropertyRelative("Key").stringValue = EditorGUILayout.TextField(property.FindPropertyRelative("Key").stringValue, GUILayout.MaxWidth(150)); + //property.FindPropertyRelative("Key").stringValue = EditorGUILayout.TextField(property.FindPropertyRelative("Key").stringValue, GUILayout.MaxWidth(150)); + DrawPropertyDropDown(originalProperty, property); filterOperatorProp.enumValueIndex = EditorGUILayout.Popup(filterOperatorProp.enumValueIndex, filterOperatorProp.enumDisplayNames, GUILayout.MaxWidth(150)); switch ((LayerFilterOperationType)filterOperatorProp.enumValueIndex) @@ -120,8 +125,38 @@ void DrawLayerFilter(SerializedProperty propertyFilters, int index) EditorGUILayout.EndVertical(); } + + private void DrawPropertyDropDown(SerializedProperty originalProperty, SerializedProperty filterProperty) + { + var selectedLayerName = originalProperty.FindPropertyRelative("_selectedLayerName").stringValue; + + if (string.IsNullOrEmpty(selectedLayerName)) + return; + + TileJsonData tileJsonData = originalProperty.FindPropertyRelative("_tileJsonData").objectReferenceValue as TileJsonData; + if (!tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName)) + return; + var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName]; + + if (propertyNamesArray != null && !Enumerable.SequenceEqual(propertyNamesArray, propertyDisplayNames.ToArray())) + index = 0; + + propertyNamesArray = propertyDisplayNames.ToArray(); + descriptionArray = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName].Values.ToArray(); + GUIContent[] properties = new GUIContent[propertyNamesArray.Length]; + for (int i = 0; i< propertyNamesArray.Length; i++) + { + properties[i] = new GUIContent(propertyNamesArray[i], descriptionArray[i]); + } + + index = EditorGUILayout.Popup(index, properties); + var parsedString = propertyNamesArray[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); + filterProperty.FindPropertyRelative("Key").stringValue = parsedString; + //EditorGUILayout.HelpBox(descriptionString, MessageType.Info); + } } + //[CustomPropertyDrawer(typeof(TypeVisualizerTuple))] //public class TypeVisualizerBaseDrawer : PropertyDrawer //{ diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index c0925d9cc..fe05d664c 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -304,7 +304,11 @@ void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProper { layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = false; } - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("filterOptions"), new GUIContent("Filters")); + var filterOptions = layerProperty.FindPropertyRelative("filterOptions"); + filterOptions.FindPropertyRelative("_tileJsonData").objectReferenceValue = tileJSONData; + filterOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue; + + EditorGUILayout.PropertyField(filterOptions, new GUIContent("Filters")); //EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("modifierOptions"), new GUIContent("Modifiers")); DrawModifiers(layerProperty, new GUIContent { text = "Modifier Options", tooltip = "Additional Feature modifiers to apply to the visualizer. " }); } diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs b/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs index c3dbe8a15..6b6af33a6 100644 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs +++ b/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs @@ -29,6 +29,10 @@ public class CoreVectorLayerProperties [Serializable] public class VectorFilterOptions { + [SerializeField] + private TileJsonData _tileJsonData; + [SerializeField] + private string _selectedLayerName = ""; public List filters = new List(); [Tooltip("Operator to combine filters. ")] public LayerFilterCombinerOperationType combinerType = LayerFilterCombinerOperationType.All; From e8c8139d3c13647e2687a42e2bf3bcc4035181f2 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Tue, 1 May 2018 00:54:36 -0700 Subject: [PATCH 06/21] hacky fix --- .../Platform/TileJSON/TileJSON.cs | 1 + .../GeometryExtrusionOptions.cs | 2 -- .../Unity/DataContainers/TileJsonData.cs | 9 +++-- .../CoreVectorLayerPropertiesDrawer.cs | 28 ++++++++++++--- .../GeometryExtrusionOptionsDrawer.cs | 34 ++++++++++++++++--- .../VectorFilterOptionsDrawer.cs | 5 +-- .../VectorLayerPropertiesDrawer.cs | 32 ++++++++++++----- .../CoreVectorLayerProperties.cs | 4 --- .../LayerProperties/VectorLayerProperties.cs | 6 ++++ .../Assets/Mapbox/Unity/Map/AbstractMap.cs | 6 ++++ 10 files changed, 97 insertions(+), 30 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/TileJSON/TileJSON.cs b/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/TileJSON/TileJSON.cs index 57b5266a0..5579e6752 100644 --- a/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/TileJSON/TileJSON.cs +++ b/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/TileJSON/TileJSON.cs @@ -37,6 +37,7 @@ public IAsyncRequest Get(string tilesetName, Action callback) { string json = Encoding.UTF8.GetString(response.Data); TileJSONResponse tileJSONResponse = JsonConvert.DeserializeObject(json); + tileJSONResponse.Source = tilesetName; callback(tileJSONResponse); } , _timeout diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryExtrusionOptions.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryExtrusionOptions.cs index 642b8641f..da5e50914 100644 --- a/sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryExtrusionOptions.cs +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryExtrusionOptions.cs @@ -16,8 +16,6 @@ public override Type ModifierType } } - [SerializeField] - private TileJsonData _tileJsonData; [SerializeField] private string _selectedLayerName = ""; public ExtrusionType extrusionType = ExtrusionType.None; diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs index 201488bfa..624f4784d 100644 --- a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs @@ -5,7 +5,8 @@ using Mapbox.Platform.TilesetTileJSON; using UnityEngine; - public class TileJsonData : ScriptableObject + [Serializable] + public class TileJsonData { public readonly string commonLayersKey = "(layer found in more than one source)"; public readonly string optionalPropertiesString = "(may not appear across all locations)"; @@ -51,12 +52,10 @@ public void ClearData() public void ProcessTileJSONData(TileJSONResponse tjr) { - TileJSONResponse response = tjr; - List layerPropertiesList = new List(); List sourceLayersList = new List(); - if (response == null || response.VectorLayers == null || response.VectorLayers.Length == 0) + if (tjr == null || tjr.VectorLayers == null || tjr.VectorLayers.Length == 0) { return; } @@ -67,7 +66,7 @@ public void ProcessTileJSONData(TileJSONResponse tjr) var propertyDescription = ""; var layerSource = ""; - foreach (var layer in response.VectorLayers) + foreach (var layer in tjr.VectorLayers) { //load layer names var layerName = layer.Id; diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index 037da49c2..f4cc52e0d 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -8,9 +8,20 @@ [CustomPropertyDrawer(typeof(CoreVectorLayerProperties))] public class CoreVectorLayerPropertiesDrawer : PropertyDrawer { - private int index = 0; - static float lineHeight = EditorGUIUtility.singleLineHeight; + int index + { + get + { + return EditorPrefs.GetInt("CoreOptions_propertySelectionIndex"); + } + set + { + EditorPrefs.SetInt("CoreOptions_propertySelectionIndex", value); + } + } + static float lineHeight = EditorGUIUtility.singleLineHeight; + static TileJsonData tileJSONData = new TileJsonData(); public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); @@ -28,8 +39,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("layerName")); - TileJsonData tileJSONData = property.FindPropertyRelative("_tileJsonData").objectReferenceValue as TileJsonData; - if (tileJSONData.LayerDisplayNames.Count > 0) + var serializedMapObject = property.serializedObject; + //serializedMapObject.Update(); + AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; + tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; + + if (tileJSONData == null || tileJSONData.LayerDisplayNames.Count <= 0) + { + tileJSONData.ProcessTileJSONData(mapObject.tileJSONResponse); + } + else { var layerDisplayNames = tileJSONData.LayerDisplayNames; var layerNamesArray = layerDisplayNames.ToArray(); @@ -54,6 +73,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } EditorGUI.EndProperty(); + //serializedMapObject.ApplyModifiedProperties(); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index a4d6ee535..0814c8929 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -5,16 +5,29 @@ using Mapbox.Unity.Map; using Mapbox.VectorTile.ExtensionMethods; using System.Linq; + using Mapbox.Platform.TilesetTileJSON; [CustomPropertyDrawer(typeof(GeometryExtrusionOptions))] public class GeometryExtrusionOptionsDrawer : PropertyDrawer { - private int index = 0; + int index + { + get + { + return EditorPrefs.GetInt("GeometryOptions_propertySelectionIndex"); + } + set + { + EditorPrefs.SetInt("GeometryOptions_propertySelectionIndex", value); + } + } + private string[] propertyNamesArray; static float lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] sourceTypeContent; bool isGUIContentSet = false; - + static TileJsonData tileJsonData = new TileJsonData(); + static TileJSONResponse tileJsonResponse; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); @@ -108,6 +121,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); EditorGUI.indentLevel--; + EditorGUI.EndProperty(); } @@ -118,9 +132,18 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) if (string.IsNullOrEmpty(selectedLayerName)) return; - TileJsonData tileJsonData = property.FindPropertyRelative("_tileJsonData").objectReferenceValue as TileJsonData; - if (!tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName)) + var serializedMapObject = property.serializedObject; + //serializedMapObject.Update(); + AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; + tileJsonData = mapObject.VectorData.LayerProperty.tileJsonData; + + + if (tileJsonData == null || !tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName)) + { return; + } + + var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName]; if (propertyNamesArray != null && !Enumerable.SequenceEqual(propertyNamesArray, propertyDisplayNames.ToArray())) @@ -135,11 +158,12 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) property.FindPropertyRelative("propertyName").stringValue = parsedString; EditorGUI.indentLevel += 2; - var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][propertyNamesArray[index]]; + var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString]; typePosition.y += lineHeight; typePosition.height = (float)(2.5f * lineHeight); EditorGUI.PrefixLabel(new Rect(position.x, typePosition.y + lineHeight/2, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Property Description", tooltip = "Factual information about the selected property" }); EditorGUI.HelpBox(typePosition,descriptionString, MessageType.Info); + //serializedMapObject.ApplyModifiedProperties(); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs index bc341bfa3..313f584b6 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs @@ -133,7 +133,9 @@ private void DrawPropertyDropDown(SerializedProperty originalProperty, Serialize if (string.IsNullOrEmpty(selectedLayerName)) return; - TileJsonData tileJsonData = originalProperty.FindPropertyRelative("_tileJsonData").objectReferenceValue as TileJsonData; + AbstractMap mapObject = (AbstractMap)originalProperty.serializedObject.targetObject; + TileJsonData tileJsonData = mapObject.VectorData.LayerProperty.tileJsonData; + if (!tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName)) return; var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName]; @@ -152,7 +154,6 @@ private void DrawPropertyDropDown(SerializedProperty originalProperty, Serialize index = EditorGUILayout.Popup(index, properties); var parsedString = propertyNamesArray[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); filterProperty.FindPropertyRelative("Key").stringValue = parsedString; - //EditorGUILayout.HelpBox(descriptionString, MessageType.Info); } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index fe05d664c..36998c9e8 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -10,16 +10,16 @@ using Mapbox.Unity.MeshGeneration.Modifiers; using Mapbox.VectorTile.ExtensionMethods; using Mapbox.Unity.MeshGeneration.Filters; + using Mapbox.Platform.TilesetTileJSON; [CustomPropertyDrawer(typeof(VectorLayerProperties))] public class VectorLayerPropertiesDrawer : PropertyDrawer { - private TileJsonData _tileJsonData; static float _lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] _sourceTypeContent; bool _isGUIContentSet = false; private TileJsonData tileJSONData; - + private static TileJSONResponse tileJSONResponse; /// /// Gets or sets the layerID /// @@ -98,6 +98,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.BeginProperty(position, label, property); position.height = _lineHeight; + var serializedMapObject = property.serializedObject; + //serializedMapObject.Update(); + AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; + //mapObject.h + //tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; + //Debug.Log("TileJSON before : " + tileJSONData.LayerDisplayNames.Count); + tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; + mapObject.tileJSONResponse = tileJSONResponse; + //Debug.Log("TileJSON after : " + tileJSONData.LayerDisplayNames.Count); + var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; @@ -260,6 +270,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } } EditorGUI.EndProperty(); + + //serializedMapObject.ApplyModifiedProperties(); } void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty) @@ -269,14 +281,12 @@ void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProper GUILayout.BeginVertical(); var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); - subLayerCoreOptions.FindPropertyRelative("_tileJsonData").objectReferenceValue = tileJSONData; VectorPrimitiveType primitiveTypeProp = (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex; EditorGUILayout.PropertyField(subLayerCoreOptions); var extrusionOptions = layerProperty.FindPropertyRelative("extrusionOptions"); - extrusionOptions.FindPropertyRelative("_tileJsonData").objectReferenceValue = tileJSONData ; //loading up the selectedLayerName for extrusion options to pull up the right propertyName extrusionOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue; @@ -305,7 +315,6 @@ void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProper layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = false; } var filterOptions = layerProperty.FindPropertyRelative("filterOptions"); - filterOptions.FindPropertyRelative("_tileJsonData").objectReferenceValue = tileJSONData; filterOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue; EditorGUILayout.PropertyField(filterOptions, new GUIContent("Filters")); @@ -420,13 +429,20 @@ private void LoadEditorTileJSON(VectorSourceType sourceTypeValue, string sourceS { if (sourceTypeValue != VectorSourceType.None && !string.IsNullOrEmpty(sourceString)) { - if (string.IsNullOrEmpty(TilesetId) || sourceString != TilesetId) + if (tileJSONResponse==null || string.IsNullOrEmpty(TilesetId) || sourceString != TilesetId) { TilesetId = sourceString; - tileJSONData = ScriptableObject.CreateInstance(); //tileJSONData.ClearData(); - Unity.MapboxAccess.Instance.TileJSON.Get(sourceString, tileJSONData.ProcessTileJSONData); + Unity.MapboxAccess.Instance.TileJSON.Get(sourceString,(response) => { + tileJSONResponse = response; + tileJSONData.ProcessTileJSONData(response); + }); } + else if(tileJSONData.LayerPropertyDescriptionDictionary.Count==0) + { + tileJSONData.ProcessTileJSONData(tileJSONResponse); + } + } else { diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs b/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs index 6b6af33a6..71822ad50 100644 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs +++ b/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs @@ -8,8 +8,6 @@ [Serializable] public class CoreVectorLayerProperties { - [SerializeField] - private TileJsonData _tileJsonData; [Tooltip("Is visualizer active.")] public bool isActive = true; [Tooltip("Name of the visualizer. ")] @@ -29,8 +27,6 @@ public class CoreVectorLayerProperties [Serializable] public class VectorFilterOptions { - [SerializeField] - private TileJsonData _tileJsonData; [SerializeField] private string _selectedLayerName = ""; public List filters = new List(); diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs b/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs index 8bf547e27..5b8e86c57 100644 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs +++ b/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs @@ -2,12 +2,18 @@ { using System; using System.Collections.Generic; + using Mapbox.Platform.TilesetTileJSON; using Mapbox.Unity.Utilities; using UnityEngine; [Serializable] public class VectorLayerProperties : LayerProperties { + /// + /// Raw tileJSON response received from the requested source tileset id(s) + /// + public TileJSONResponse tileJSONResponse; + public TileJsonData tileJsonData = new TileJsonData(); public VectorSourceType sourceType = VectorSourceType.MapboxStreets; public LayerSourceOptions sourceOptions = new LayerSourceOptions() { diff --git a/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs b/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs index 14b8ccb30..9c7076221 100644 --- a/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs +++ b/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs @@ -9,6 +9,7 @@ namespace Mapbox.Unity.Map using Mapbox.Map; using Mapbox.Unity.MeshGeneration.Factories; using Mapbox.Unity.MeshGeneration.Data; + using Mapbox.Platform.TilesetTileJSON; public interface IUnifiedMap { @@ -661,6 +662,11 @@ public void SetLoadingTexture(Texture2D loadingTexture) Options.loadingTexture = loadingTexture; _mapVisualizer.SetLoadingTexture(loadingTexture); } + + /// + /// Raw tileJSON response received from the requested source tileset id(s) + /// + public TileJSONResponse tileJSONResponse; } } From 2e3e6223a487efc286dbf5547c929256fe558a3d Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Tue, 1 May 2018 01:21:21 -0700 Subject: [PATCH 07/21] fixed indices --- .../PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs | 9 +++++++-- .../PropertyDrawers/GeometryExtrusionOptionsDrawer.cs | 2 +- sdkproject/ProjectSettings/ProjectVersion.txt | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index f4cc52e0d..1e9a42e3e 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -4,6 +4,7 @@ using UnityEngine; using Mapbox.Unity.Map; using System.Collections.Generic; + using System.Linq; [CustomPropertyDrawer(typeof(CoreVectorLayerProperties))] public class CoreVectorLayerPropertiesDrawer : PropertyDrawer @@ -20,6 +21,7 @@ int index } } + private string[] layerNamesArray; static float lineHeight = EditorGUIUtility.singleLineHeight; static TileJsonData tileJSONData = new TileJsonData(); public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) @@ -44,14 +46,17 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; - if (tileJSONData == null || tileJSONData.LayerDisplayNames.Count <= 0) + if (tileJSONData == null || tileJSONData.LayerDisplayNames.Count == 0) { tileJSONData.ProcessTileJSONData(mapObject.tileJSONResponse); } else { var layerDisplayNames = tileJSONData.LayerDisplayNames; - var layerNamesArray = layerDisplayNames.ToArray(); + if (layerNamesArray == null || !Enumerable.SequenceEqual(layerNamesArray, layerDisplayNames.ToArray())) + index = 0; + + layerNamesArray = layerDisplayNames.ToArray(); typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Layer Name", tooltip = "The layer name from the Mapbox tileset that would be used for visualizing a feature" }); EditorGUI.indentLevel--; index = EditorGUI.Popup(typePosition, index, layerNamesArray); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index 0814c8929..66ea210a9 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -146,7 +146,7 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName]; - if (propertyNamesArray != null && !Enumerable.SequenceEqual(propertyNamesArray, propertyDisplayNames.ToArray())) + if (propertyNamesArray == null || !Enumerable.SequenceEqual(propertyNamesArray, propertyDisplayNames.ToArray())) index = 0; propertyNamesArray = propertyDisplayNames.ToArray(); diff --git a/sdkproject/ProjectSettings/ProjectVersion.txt b/sdkproject/ProjectSettings/ProjectVersion.txt index ac7d21464..27997c5a0 100644 --- a/sdkproject/ProjectSettings/ProjectVersion.txt +++ b/sdkproject/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2017.4.0f1 +m_EditorVersion: 2017.3.1f1 From ff19f3e17f8aa7953f151bda338131a4b28e7842 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Tue, 1 May 2018 13:05:13 -0700 Subject: [PATCH 08/21] adding unity objectId to editorprefs --- .../Mapbox/Unity/Editor/MapManagerEditor.cs | 23 +++++++++-------- .../CoreVectorLayerPropertiesDrawer.cs | 6 +++-- .../ElevationLayerPropertiesDrawer.cs | 11 +++++--- .../GeometryExtrusionOptionsDrawer.cs | 6 +++-- .../ImageryLayerPropertiesDrawer.cs | 6 +++-- .../VectorLayerPropertiesDrawer.cs | 25 +++++++++++-------- sdkproject/ProjectSettings/ProjectVersion.txt | 2 +- 7 files changed, 47 insertions(+), 32 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 229db5ab7..5fb1eeb0a 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -10,6 +10,8 @@ [CanEditMultipleObjects] public class MapManagerEditor : Editor { + + private string objectId = ""; /// /// Gets or sets a value indicating whether to show general section . /// @@ -18,11 +20,11 @@ bool ShowGeneral { get { - return EditorPrefs.GetBool("MapManagerEditor_showGeneral"); + return EditorPrefs.GetBool(objectId + "MapManagerEditor_showGeneral"); } set { - EditorPrefs.SetBool("MapManagerEditor_showGeneral", value); + EditorPrefs.SetBool(objectId + "MapManagerEditor_showGeneral", value); } } /// @@ -33,11 +35,11 @@ bool ShowImage { get { - return EditorPrefs.GetBool("MapManagerEditor_showImage"); + return EditorPrefs.GetBool(objectId + "MapManagerEditor_showImage"); } set { - EditorPrefs.SetBool("MapManagerEditor_showImage", value); + EditorPrefs.SetBool(objectId + "MapManagerEditor_showImage", value); } } /// @@ -48,11 +50,11 @@ bool ShowTerrain { get { - return EditorPrefs.GetBool("MapManagerEditor_showTerrain"); + return EditorPrefs.GetBool(objectId + "MapManagerEditor_showTerrain"); } set { - EditorPrefs.SetBool("MapManagerEditor_showTerrain", value); + EditorPrefs.SetBool(objectId + "MapManagerEditor_showTerrain", value); } } /// @@ -63,11 +65,11 @@ bool ShowVector { get { - return EditorPrefs.GetBool("MapManagerEditor_showVector"); + return EditorPrefs.GetBool(objectId + "MapManagerEditor_showVector"); } set { - EditorPrefs.SetBool("MapManagerEditor_showVector", value); + EditorPrefs.SetBool(objectId + "MapManagerEditor_showVector", value); } } @@ -75,16 +77,17 @@ bool ShowPosition { get { - return EditorPrefs.GetBool("MapManagerEditor_showPosition"); + return EditorPrefs.GetBool(objectId + "MapManagerEditor_showPosition"); } set { - EditorPrefs.SetBool("MapManagerEditor_showPosition", value); + EditorPrefs.SetBool(objectId + "MapManagerEditor_showPosition", value); } } public override void OnInspectorGUI() { + objectId = serializedObject.targetObject.GetInstanceID().ToString(); serializedObject.Update(); GUILayout.BeginVertical(); EditorGUILayout.Space(); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index 1e9a42e3e..764522b20 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -13,19 +13,21 @@ int index { get { - return EditorPrefs.GetInt("CoreOptions_propertySelectionIndex"); + return EditorPrefs.GetInt(objectId + "CoreOptions_propertySelectionIndex"); } set { - EditorPrefs.SetInt("CoreOptions_propertySelectionIndex", value); + EditorPrefs.SetInt(objectId + "CoreOptions_propertySelectionIndex", value); } } + string objectId = ""; private string[] layerNamesArray; static float lineHeight = EditorGUIUtility.singleLineHeight; static TileJsonData tileJSONData = new TileJsonData(); public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); EditorGUI.BeginProperty(position, label, property); position.height = lineHeight; diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs index c73d7b001..281d69d47 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs @@ -8,6 +8,7 @@ [CustomPropertyDrawer(typeof(ElevationLayerProperties))] public class ElevationLayerPropertiesDrawer : PropertyDrawer { + string objectId = ""; static float lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] sourceTypeContent; bool isGUIContentSet = false; @@ -16,11 +17,11 @@ bool ShowPosition { get { - return EditorPrefs.GetBool("ElevationLayerProperties_showPosition"); + return EditorPrefs.GetBool(objectId + "ElevationLayerProperties_showPosition"); } set { - EditorPrefs.SetBool("ElevationLayerProperties_showPosition", value); + EditorPrefs.SetBool(objectId + "ElevationLayerProperties_showPosition", value); } } @@ -34,16 +35,18 @@ string CustomSourceMapId { get { - return EditorPrefs.GetString("ElevationLayerProperties_customSourceMapId"); + return EditorPrefs.GetString(objectId + "ElevationLayerProperties_customSourceMapId"); } set { - EditorPrefs.SetString("ElevationLayerProperties_customSourceMapId", value); + EditorPrefs.SetString(objectId + "ElevationLayerProperties_customSourceMapId", value); } } public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); + EditorGUI.BeginProperty(position, label, property); position.height = lineHeight; diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index 66ea210a9..75c55f172 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -14,14 +14,15 @@ int index { get { - return EditorPrefs.GetInt("GeometryOptions_propertySelectionIndex"); + return EditorPrefs.GetInt(objectId + "GeometryOptions_propertySelectionIndex"); } set { - EditorPrefs.SetInt("GeometryOptions_propertySelectionIndex", value); + EditorPrefs.SetInt(objectId + "GeometryOptions_propertySelectionIndex", value); } } + string objectId = ""; private string[] propertyNamesArray; static float lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] sourceTypeContent; @@ -30,6 +31,7 @@ int index static TileJSONResponse tileJsonResponse; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); EditorGUI.BeginProperty(position, label, property); var extrusionTypeProperty = property.FindPropertyRelative("extrusionType"); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs index 28b5678ad..76fabef7a 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs @@ -8,6 +8,7 @@ [CustomPropertyDrawer(typeof(ImageryLayerProperties))] public class ImageryLayerPropertiesDrawer : PropertyDrawer { + string objectId = ""; static float lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] sourceTypeContent; @@ -23,16 +24,17 @@ string CustomSourceMapId { get { - return EditorPrefs.GetString("ImageryLayerProperties_customSourceMapId"); + return EditorPrefs.GetString(objectId + "ImageryLayerProperties_customSourceMapId"); } set { - EditorPrefs.SetString("ImageryLayerProperties_customSourceMapId", value); + EditorPrefs.SetString(objectId + "ImageryLayerProperties_customSourceMapId", value); } } public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); EditorGUI.BeginProperty(position, label, property); position.height = lineHeight; diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 36998c9e8..7ec157f45 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -24,15 +24,18 @@ public class VectorLayerPropertiesDrawer : PropertyDrawer /// Gets or sets the layerID /// /// true then show general section; otherwise hide, false. + + + string objectId = ""; private string TilesetId { get { - return EditorPrefs.GetString("MapManagerEditor_tilesetId"); + return EditorPrefs.GetString(objectId+"MapManagerEditor_tilesetId"); } set { - EditorPrefs.SetString("MapManagerEditor_tilesetId", value); + EditorPrefs.SetString(objectId +"MapManagerEditor_tilesetId", value); } } @@ -40,11 +43,11 @@ bool ShowPosition { get { - return EditorPrefs.GetBool("VectorLayerProperties_showPosition"); + return EditorPrefs.GetBool(objectId +"VectorLayerProperties_showPosition"); } set { - EditorPrefs.SetBool("VectorLayerProperties_showPosition", value); + EditorPrefs.SetBool(objectId +"VectorLayerProperties_showPosition", value); } } @@ -52,11 +55,11 @@ bool ShowOthers { get { - return EditorPrefs.GetBool("VectorLayerProperties_showOthers"); + return EditorPrefs.GetBool(objectId +"VectorLayerProperties_showOthers"); } set { - EditorPrefs.SetBool("VectorLayerProperties_showOthers", value); + EditorPrefs.SetBool(objectId +"VectorLayerProperties_showOthers", value); } } @@ -64,11 +67,11 @@ int SelectionIndex { get { - return EditorPrefs.GetInt("VectorLayerProperties_selectionIndex"); + return EditorPrefs.GetInt(objectId +"VectorLayerProperties_selectionIndex"); } set { - EditorPrefs.SetInt("VectorLayerProperties_selectionIndex", value); + EditorPrefs.SetInt(objectId +"VectorLayerProperties_selectionIndex", value); } } @@ -76,11 +79,11 @@ string CustomSourceMapId { get { - return EditorPrefs.GetString("VectorLayerProperties_customSourceMapId"); + return EditorPrefs.GetString(objectId +"VectorLayerProperties_customSourceMapId"); } set { - EditorPrefs.SetString("VectorLayerProperties_customSourceMapId", value); + EditorPrefs.SetString(objectId +"VectorLayerProperties_customSourceMapId", value); } } @@ -95,6 +98,7 @@ string CustomSourceMapId public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); EditorGUI.BeginProperty(position, label, property); position.height = _lineHeight; @@ -107,7 +111,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; mapObject.tileJSONResponse = tileJSONResponse; //Debug.Log("TileJSON after : " + tileJSONData.LayerDisplayNames.Count); - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; diff --git a/sdkproject/ProjectSettings/ProjectVersion.txt b/sdkproject/ProjectSettings/ProjectVersion.txt index 27997c5a0..ac7d21464 100644 --- a/sdkproject/ProjectSettings/ProjectVersion.txt +++ b/sdkproject/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2017.3.1f1 +m_EditorVersion: 2017.4.0f1 From 8d3f29d9c1afa55a87036acfd259edcbdc61e4d4 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Wed, 2 May 2018 21:02:41 -0700 Subject: [PATCH 09/21] mysterious unexplained behaviour.. handled it with a hack --- .../Core/mapbox-sdk-cs/Map/VectorTile.cs | 1 - .../CoreVectorLayerPropertiesDrawer.cs | 51 ++++++++++++++----- .../GeometryExtrusionOptionsDrawer.cs | 41 +++++++++++---- .../VectorLayerPropertiesDrawer.cs | 20 ++++++-- 4 files changed, 85 insertions(+), 28 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Map/VectorTile.cs b/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Map/VectorTile.cs index 57549d8cc..53a72bbf4 100644 --- a/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Map/VectorTile.cs +++ b/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Map/VectorTile.cs @@ -197,7 +197,6 @@ internal override bool ParseTileData(byte[] data) { var decompressed = Compression.Decompress(data); this.data = new Mapbox.VectorTile.VectorTile(decompressed); - return true; } catch (Exception ex) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index 764522b20..6db6f5565 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -5,6 +5,7 @@ using Mapbox.Unity.Map; using System.Collections.Generic; using System.Linq; + using System; [CustomPropertyDrawer(typeof(CoreVectorLayerProperties))] public class CoreVectorLayerPropertiesDrawer : PropertyDrawer @@ -21,8 +22,9 @@ int index } } + static List layerNameList = new List(); + bool _isInitialized = false; string objectId = ""; - private string[] layerNamesArray; static float lineHeight = EditorGUIUtility.singleLineHeight; static TileJsonData tileJSONData = new TileJsonData(); public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) @@ -48,25 +50,18 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; - if (tileJSONData == null || tileJSONData.LayerDisplayNames.Count == 0) + var layerDisplayNames = tileJSONData.LayerDisplayNames; + if (_isInitialized == true) { - tileJSONData.ProcessTileJSONData(mapObject.tileJSONResponse); + DrawLayerName(property, position, layerDisplayNames); } else { - var layerDisplayNames = tileJSONData.LayerDisplayNames; - if (layerNamesArray == null || !Enumerable.SequenceEqual(layerNamesArray, layerDisplayNames.ToArray())) - index = 0; - - layerNamesArray = layerDisplayNames.ToArray(); - typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Layer Name", tooltip = "The layer name from the Mapbox tileset that would be used for visualizing a feature" }); - EditorGUI.indentLevel--; - index = EditorGUI.Popup(typePosition, index, layerNamesArray); - var parsedString = layerNamesArray[index].Split(new string[] { tileJSONData.commonLayersKey }, System.StringSplitOptions.None)[0].Trim(); - property.FindPropertyRelative("layerName").stringValue = parsedString; - EditorGUI.indentLevel++; + _isInitialized = true; + //DrawLayerName(property, position, layerDisplayNames); } + position.y += lineHeight; EditorGUI.PropertyField(position, property.FindPropertyRelative("snapToTerrain")); @@ -82,6 +77,34 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.EndProperty(); //serializedMapObject.ApplyModifiedProperties(); } + private static int count = 0; + private void DrawLayerName(SerializedProperty property,Rect position,List layerDisplayNames) + { + if (layerDisplayNames.Count == 0) + return; + + if(layerDisplayNames.Count!=count) + { + count = layerDisplayNames.Count; + } + if (!layerDisplayNames.SequenceEqual(layerNameList)) + { + index = 0; + layerNameList = layerDisplayNames; + } + + if(layerNameList.Count propertyNamesList = new List(); static float lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] sourceTypeContent; bool isGUIContentSet = false; @@ -148,24 +150,43 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName]; - if (propertyNamesArray == null || !Enumerable.SequenceEqual(propertyNamesArray, propertyDisplayNames.ToArray())) - index = 0; - - propertyNamesArray = propertyDisplayNames.ToArray(); + if (_isInitialized == true) + { + if (!Enumerable.SequenceEqual(propertyNamesList, propertyDisplayNames)) + { + index = 0; + propertyNamesList = propertyDisplayNames; + } + else + { + DrawPropertyName(property, position, propertyDisplayNames, selectedLayerName); + } + } + else + { + _isInitialized = true; + DrawPropertyName(property, position, propertyDisplayNames, selectedLayerName); + } + + //serializedMapObject.ApplyModifiedProperties(); + } + + private void DrawPropertyName(SerializedProperty property, Rect position, ListpropertyDisplayNames, string selectedLayerName) + { + propertyNamesList = propertyDisplayNames; Rect typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" }); EditorGUI.indentLevel -= 2; - index = EditorGUI.Popup(typePosition, index, propertyNamesArray); + index = EditorGUI.Popup(typePosition, index, propertyNamesList.ToArray()); position.y += lineHeight; - var parsedString = propertyNamesArray[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); + var parsedString = propertyNamesList.ToArray()[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); property.FindPropertyRelative("propertyName").stringValue = parsedString; EditorGUI.indentLevel += 2; var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString]; typePosition.y += lineHeight; typePosition.height = (float)(2.5f * lineHeight); - EditorGUI.PrefixLabel(new Rect(position.x, typePosition.y + lineHeight/2, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Property Description", tooltip = "Factual information about the selected property" }); - EditorGUI.HelpBox(typePosition,descriptionString, MessageType.Info); - //serializedMapObject.ApplyModifiedProperties(); + EditorGUI.PrefixLabel(new Rect(position.x, typePosition.y + lineHeight / 2, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Property Description", tooltip = "Factual information about the selected property" }); + EditorGUI.HelpBox(typePosition, descriptionString, MessageType.Info); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 7ec157f45..088826073 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -18,6 +18,7 @@ public class VectorLayerPropertiesDrawer : PropertyDrawer static float _lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] _sourceTypeContent; bool _isGUIContentSet = false; + bool _isInitialized = false; private TileJsonData tileJSONData; private static TileJSONResponse tileJSONResponse; /// @@ -147,15 +148,28 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); - LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); + if (_isInitialized) + { + LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); + } + else + { + _isInitialized = true; + } GUI.enabled = true; isActiveProperty.boolValue = true; break; case VectorSourceType.Custom: layerSourceId.stringValue = CustomSourceMapId; EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); - LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); - CustomSourceMapId = layerSourceId.stringValue; + if (_isInitialized) + { + LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); + } + else + { + _isInitialized = true; + } CustomSourceMapId = layerSourceId.stringValue; isActiveProperty.boolValue = true; break; case VectorSourceType.None: From a4b0018478cd96328ad054dafd4050a508e79528 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Thu, 3 May 2018 13:38:56 -0700 Subject: [PATCH 10/21] solid fix this time.. mystery resolved -Sherlock Holmes --- .../Unity/Editor/EditorTileJsonProps.cs | 11 ++++ .../CoreVectorLayerPropertiesDrawer.cs | 38 ++++++-------- .../VectorFilterOptionsDrawer.cs | 52 ++++++++++++++----- .../VectorLayerPropertiesDrawer.cs | 8 +-- .../CoreVectorLayerProperties.cs | 2 + 5 files changed, 74 insertions(+), 37 deletions(-) create mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJsonProps.cs diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJsonProps.cs b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJsonProps.cs new file mode 100644 index 000000000..34677c2de --- /dev/null +++ b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJsonProps.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +/// +/// Class used to store non serialized editor properties +/// +public class EditorTileJsonProps +{ + public static List propertyNamesList = new List(); + public static List layerNamesList = new List(); + +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index 6db6f5565..9b7588be6 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -22,9 +22,9 @@ int index } } - static List layerNameList = new List(); - bool _isInitialized = false; + static bool _isInitialized = false; string objectId = ""; + static string currentSource = ""; static float lineHeight = EditorGUIUtility.singleLineHeight; static TileJsonData tileJSONData = new TileJsonData(); public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) @@ -51,17 +51,25 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; var layerDisplayNames = tileJSONData.LayerDisplayNames; - if (_isInitialized == true) + + var newSource = property.FindPropertyRelative("sourceId").stringValue; + + if(_isInitialized) { + if (currentSource != newSource) + { + index = 0; + } + currentSource = newSource; + DrawLayerName(property, position, layerDisplayNames); } else { _isInitialized = true; - //DrawLayerName(property, position, layerDisplayNames); + currentSource = newSource; } - position.y += lineHeight; EditorGUI.PropertyField(position, property.FindPropertyRelative("snapToTerrain")); @@ -83,25 +91,11 @@ private void DrawLayerName(SerializedProperty property,Rect position,List(); - GUIContent[] properties = new GUIContent[propertyNamesArray.Length]; - for (int i = 0; i< propertyNamesArray.Length; i++) + GUIContent[] properties = new GUIContent[propertyDisplayNames.Count]; + for (int i = 0; i< propertyDisplayNames.Count; i++) { - properties[i] = new GUIContent(propertyNamesArray[i], descriptionArray[i]); + properties[i] = new GUIContent(propertyDisplayNames[i], descriptionArray[i]); } - index = EditorGUILayout.Popup(index, properties); - var parsedString = propertyNamesArray[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); + propertyIndex = EditorGUILayout.Popup(propertyIndex, properties); + var parsedString = propertyDisplayNames[propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); filterProperty.FindPropertyRelative("Key").stringValue = parsedString; } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 088826073..dd10e7c4a 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -229,7 +229,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten subLayerCoreOptions.FindPropertyRelative("snapToTerrain").boolValue = true; subLayerCoreOptions.FindPropertyRelative("groupFeatures").boolValue = false; subLayerCoreOptions.FindPropertyRelative("lineWidth").floatValue = 1.0f; - + var subLayerExtrusionOptions = subLayer.FindPropertyRelative("extrusionOptions"); subLayerExtrusionOptions.FindPropertyRelative("extrusionType").enumValueIndex = (int)ExtrusionType.None; subLayerExtrusionOptions.FindPropertyRelative("extrusionGeometryType").enumValueIndex = (int)ExtrusionGeometryType.RoofAndSide; @@ -279,7 +279,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var layerProperty = subLayerArray.GetArrayElementAtIndex(SelectionIndex); layerProperty.isExpanded = true; - DrawLayerVisualizerProperties(sourceTypeValue,layerProperty); + DrawLayerVisualizerProperties(sourceTypeValue,layerProperty, property); } else { @@ -291,7 +291,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten //serializedMapObject.ApplyModifiedProperties(); } - void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty) + void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty, SerializedProperty property) { EditorGUI.indentLevel++; GUILayout.Label("Vector Layer Visualizer Properties"); @@ -303,6 +303,8 @@ void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProper EditorGUILayout.PropertyField(subLayerCoreOptions); + subLayerCoreOptions.FindPropertyRelative("sourceId").stringValue = property.FindPropertyRelative("sourceOptions.layerSource.Id").stringValue; + var extrusionOptions = layerProperty.FindPropertyRelative("extrusionOptions"); //loading up the selectedLayerName for extrusion options to pull up the right propertyName extrusionOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue; diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs b/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs index 71822ad50..bd3f71b67 100644 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs +++ b/sdkproject/Assets/Mapbox/Unity/LayerProperties/CoreVectorLayerProperties.cs @@ -8,6 +8,8 @@ [Serializable] public class CoreVectorLayerProperties { + [SerializeField] + private string sourceId = ""; [Tooltip("Is visualizer active.")] public bool isActive = true; [Tooltip("Name of the visualizer. ")] From 6849b5b0dff43bc26aefdeeb0796e5b31fcb0767 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Thu, 3 May 2018 16:39:52 -0700 Subject: [PATCH 11/21] added warning for invalid tilejson response --- .../Platform/TileJSON/TileJSON.cs | 5 +- .../Unity/Editor/EditorTileJsonProps.cs | 11 ---- .../CoreVectorLayerPropertiesDrawer.cs | 17 +++--- .../GeometryExtrusionOptionsDrawer.cs | 54 ++++++++++++++----- .../VectorFilterOptionsDrawer.cs | 19 +++++-- .../VectorLayerPropertiesDrawer.cs | 24 +++++---- .../LayerProperties/VectorLayerProperties.cs | 1 - .../Assets/Mapbox/Unity/Map/AbstractMap.cs | 5 -- 8 files changed, 84 insertions(+), 52 deletions(-) delete mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJsonProps.cs diff --git a/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/TileJSON/TileJSON.cs b/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/TileJSON/TileJSON.cs index 5579e6752..0491354e4 100644 --- a/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/TileJSON/TileJSON.cs +++ b/sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Platform/TileJSON/TileJSON.cs @@ -37,7 +37,10 @@ public IAsyncRequest Get(string tilesetName, Action callback) { string json = Encoding.UTF8.GetString(response.Data); TileJSONResponse tileJSONResponse = JsonConvert.DeserializeObject(json); - tileJSONResponse.Source = tilesetName; + if (tileJSONResponse != null) + { + tileJSONResponse.Source = tilesetName; + } callback(tileJSONResponse); } , _timeout diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJsonProps.cs b/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJsonProps.cs deleted file mode 100644 index 34677c2de..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/EditorTileJsonProps.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -/// -/// Class used to store non serialized editor properties -/// -public class EditorTileJsonProps -{ - public static List propertyNamesList = new List(); - public static List layerNamesList = new List(); - -} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index 9b7588be6..be28db34f 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -26,7 +26,7 @@ int index string objectId = ""; static string currentSource = ""; static float lineHeight = EditorGUIUtility.singleLineHeight; - static TileJsonData tileJSONData = new TileJsonData(); + static TileJsonData tileJsonData = new TileJsonData(); public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); @@ -48,9 +48,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var serializedMapObject = property.serializedObject; //serializedMapObject.Update(); AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; - tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; + tileJsonData = mapObject.VectorData.LayerProperty.tileJsonData; - var layerDisplayNames = tileJSONData.LayerDisplayNames; + var layerDisplayNames = tileJsonData.LayerDisplayNames; var newSource = property.FindPropertyRelative("sourceId").stringValue; @@ -88,14 +88,19 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten private static int count = 0; private void DrawLayerName(SerializedProperty property,Rect position,List layerDisplayNames) { + var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Layer Name", tooltip = "The layer name from the Mapbox tileset that would be used for visualizing a feature" }); + if (layerDisplayNames.Count == 0) + { + EditorGUI.indentLevel--; + EditorGUI.HelpBox(typePosition, "No layers found : Invalid MapId / No Internet.", MessageType.None); + EditorGUI.indentLevel++; return; + } - //EditorTileJsonProps.layerNamesList = layerDisplayNames; - var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Layer Name", tooltip = "The layer name from the Mapbox tileset that would be used for visualizing a feature" }); EditorGUI.indentLevel--; index = EditorGUI.Popup(typePosition, index, layerDisplayNames.ToArray()); - var parsedString = layerDisplayNames.ToArray()[index].Split(new string[] { tileJSONData.commonLayersKey }, System.StringSplitOptions.None)[0].Trim(); + var parsedString = layerDisplayNames.ToArray()[index].Split(new string[] { tileJsonData.commonLayersKey }, System.StringSplitOptions.None)[0].Trim(); property.FindPropertyRelative("layerName").stringValue = parsedString; EditorGUI.indentLevel++; } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index ea72c9d81..0eba25d4c 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -31,6 +31,7 @@ int index bool isGUIContentSet = false; static TileJsonData tileJsonData = new TileJsonData(); static TileJSONResponse tileJsonResponse; + static bool dataUnavailable = false; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); @@ -77,7 +78,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); - position.y += 2.5f *lineHeight; + if (!dataUnavailable) + { + position.y += 2.5f * lineHeight; + } break; case Unity.Map.ExtrusionType.MinHeight: position.y += lineHeight; @@ -85,15 +89,20 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); - position.y += 2.5f * lineHeight; - break; + if (!dataUnavailable) + { + position.y += 2.5f * lineHeight; + } break; case Unity.Map.ExtrusionType.MaxHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); - position.y += 2.5f * lineHeight; + if (!dataUnavailable) + { + position.y += 2.5f * lineHeight; + } break; case Unity.Map.ExtrusionType.RangeHeight: position.y += lineHeight; @@ -101,7 +110,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); - position.y += 2.5f * lineHeight; + if (!dataUnavailable) + { + position.y += 2.5f * lineHeight; + } position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), minHeightProperty); position.y += lineHeight; @@ -121,7 +133,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten default: break; } - position.y += lineHeight; + position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); EditorGUI.indentLevel--; @@ -133,21 +145,19 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) { var selectedLayerName = property.FindPropertyRelative("_selectedLayerName").stringValue; - if (string.IsNullOrEmpty(selectedLayerName)) - return; - var serializedMapObject = property.serializedObject; //serializedMapObject.Update(); AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; tileJsonData = mapObject.VectorData.LayerProperty.tileJsonData; - if (tileJsonData == null || !tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName)) + if (string.IsNullOrEmpty(selectedLayerName) || tileJsonData == null || !tileJsonData.PropertyDisplayNames.ContainsKey(selectedLayerName)) { + DrawWarningMessage(position); return; } - + dataUnavailable = false; var propertyDisplayNames = tileJsonData.PropertyDisplayNames[selectedLayerName]; if (_isInitialized == true) @@ -189,6 +199,16 @@ private void DrawPropertyName(SerializedProperty property, Rect position, List(); @@ -183,6 +185,13 @@ private void DrawPropertyDropDown(SerializedProperty originalProperty, Serialize var parsedString = propertyDisplayNames[propertyIndex].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); filterProperty.FindPropertyRelative("Key").stringValue = parsedString; } + + private void DrawWarningMessage() + { + dataUnavailable = true; + EditorGUILayout.HelpBox("Check MapId / Internet.", MessageType.None); + return; + } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index dd10e7c4a..f54787b3c 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -104,14 +104,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.height = _lineHeight; var serializedMapObject = property.serializedObject; - //serializedMapObject.Update(); AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; - //mapObject.h - //tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; - //Debug.Log("TileJSON before : " + tileJSONData.LayerDisplayNames.Count); tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; - mapObject.tileJSONResponse = tileJSONResponse; - //Debug.Log("TileJSON after : " + tileJSONData.LayerDisplayNames.Count); var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; @@ -156,6 +150,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { _isInitialized = true; } + if(tileJSONData.PropertyDisplayNames.Count==0) + { + EditorGUILayout.HelpBox("Invalid Map Id / There might be a problem with the internet connection.", MessageType.Error); + } GUI.enabled = true; isActiveProperty.boolValue = true; break; @@ -169,7 +167,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten else { _isInitialized = true; - } CustomSourceMapId = layerSourceId.stringValue; + } + if (tileJSONData.PropertyDisplayNames.Count == 0) + { + 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: @@ -287,8 +290,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } } EditorGUI.EndProperty(); - - //serializedMapObject.ApplyModifiedProperties(); } void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty, SerializedProperty property) @@ -454,6 +455,11 @@ private void LoadEditorTileJSON(VectorSourceType sourceTypeValue, string sourceS //tileJSONData.ClearData(); Unity.MapboxAccess.Instance.TileJSON.Get(sourceString,(response) => { tileJSONResponse = response; + if(response == null || response.VectorLayers == null) //indicates bad tileresponse + { + tileJSONData.ClearData(); + return; + } tileJSONData.ProcessTileJSONData(response); }); } diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs b/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs index 5b8e86c57..6b04ea334 100644 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs +++ b/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs @@ -12,7 +12,6 @@ public class VectorLayerProperties : LayerProperties /// /// Raw tileJSON response received from the requested source tileset id(s) /// - public TileJSONResponse tileJSONResponse; public TileJsonData tileJsonData = new TileJsonData(); public VectorSourceType sourceType = VectorSourceType.MapboxStreets; public LayerSourceOptions sourceOptions = new LayerSourceOptions() diff --git a/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs b/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs index 9c7076221..b9cfd98be 100644 --- a/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs +++ b/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs @@ -662,11 +662,6 @@ public void SetLoadingTexture(Texture2D loadingTexture) Options.loadingTexture = loadingTexture; _mapVisualizer.SetLoadingTexture(loadingTexture); } - - /// - /// Raw tileJSON response received from the requested source tileset id(s) - /// - public TileJSONResponse tileJSONResponse; } } From 7e6dd65ccdeaf1b334e882358f09f71839a6dd86 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 4 May 2018 10:07:00 -0700 Subject: [PATCH 12/21] basic cosmetic changes in --- .../Mapbox/Unity/Editor/MapManagerEditor.cs | 77 ++++++++++++------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 0dc0f1c7e..933baf1f2 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -53,6 +53,23 @@ bool ShowTerrain EditorPrefs.SetBool("MapManagerEditor_showTerrain", value); } } + + /// + /// Gets or sets a value show or hide Map Layers section show features. + /// + /// true if show features; otherwise, false. + bool ShowMapLayers + { + get + { + return EditorPrefs.GetBool("MapManagerEditor_showMapLayers"); + } + set + { + EditorPrefs.SetBool("MapManagerEditor_showMapLayers", value); + } + } + /// /// Gets or sets a value to show or hide Vector section . /// @@ -73,7 +90,7 @@ bool ShowLocationPrefabs /// Gets or sets a value to show or hide Vector section . /// /// true if show vector; otherwise, false. - bool ShowVector + bool ShowFeatures { get { @@ -135,38 +152,42 @@ public override void OnInspectorGUI() ShowSepartor(); - ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "LOCATION PREFABS"); - if (ShowLocationPrefabs) + ShowMapLayers = EditorGUILayout.Foldout(ShowMapLayers, "MAP LAYERS"); + if (ShowMapLayers) { - var vectorDataProperty = serializedObject.FindProperty("_vectorData"); - - - var layerProperty = vectorDataProperty.FindPropertyRelative("_layerProperty"); - var layerSourceProperty = layerProperty.FindPropertyRelative("sourceOptions"); - var sourceType = layerProperty.FindPropertyRelative("_sourceType"); - VectorSourceType sourceTypeValue = (VectorSourceType)sourceType.enumValueIndex; - string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; - string layerString = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id").stringValue; - - if(sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7)) + EditorGUI.indentLevel++; + ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "LOCATION PREFABS"); + if (ShowLocationPrefabs) { - GUI.enabled = false; - EditorGUILayout.TextField(_mapIdGui, streets_v7); - GUI.enabled = true; - ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties"); + var vectorDataProperty = serializedObject.FindProperty("_vectorData"); + + + var layerProperty = vectorDataProperty.FindPropertyRelative("_layerProperty"); + var layerSourceProperty = layerProperty.FindPropertyRelative("sourceOptions"); + var sourceType = layerProperty.FindPropertyRelative("_sourceType"); + VectorSourceType sourceTypeValue = (VectorSourceType)sourceType.enumValueIndex; + string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; + string layerString = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id").stringValue; + + if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7)) + { + GUI.enabled = false; + EditorGUILayout.TextField(_mapIdGui, 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); + } } - else + + ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES"); + if (ShowFeatures) { - EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source in the Vector section.",MessageType.Error); + ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); } - } - - ShowSepartor(); - - ShowVector = EditorGUILayout.Foldout(ShowVector, "VECTOR"); - if (ShowVector) - { - ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); + EditorGUI.indentLevel--; } GUILayout.EndVertical(); From f940aee25858b5687bd1f84bd7e926b31d3e8f88 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 4 May 2018 11:07:54 -0700 Subject: [PATCH 13/21] ui issue fixed --- .../Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs index a3fa18b81..9c66d62a0 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs @@ -65,11 +65,10 @@ protected override void RowGUI (RowGUIArgs args) { Rect toggleRect = args.rowRect; toggleRect.width = kToggleWidth; - var item = Layers.GetArrayElementAtIndex(args.item.id); item.FindPropertyRelative("coreOptions.isActive").boolValue = EditorGUI.Toggle(toggleRect, item.FindPropertyRelative("coreOptions.isActive").boolValue); + args.rowRect.x += kToggleWidth; args.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue; - base.RowGUI(args); } From 2070520875c5ebc539e4513fb253611f52dae279 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 4 May 2018 13:32:59 -0700 Subject: [PATCH 14/21] duplicate layers taken care of --- .../Mapbox/Unity/Editor/MapManagerEditor.cs | 4 +- .../LayerProperties/VectorLayerProperties.cs | 1 + .../Assets/Mapbox/Unity/Map/AbstractMap.cs | 14 +--- .../Factories/VectorTileFactory.cs | 28 +++++--- .../Mapbox/Unity/SourceLayers/VectorLayer.cs | 67 +++++++++++++------ 5 files changed, 71 insertions(+), 43 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 933baf1f2..21598b2d9 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -156,7 +156,7 @@ public override void OnInspectorGUI() if (ShowMapLayers) { EditorGUI.indentLevel++; - ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "LOCATION PREFABS"); + ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST"); if (ShowLocationPrefabs) { var vectorDataProperty = serializedObject.FindProperty("_vectorData"); @@ -181,7 +181,7 @@ public override void OnInspectorGUI() 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) { diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs b/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs index 8dc90db9b..2a8559136 100644 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs +++ b/sdkproject/Assets/Mapbox/Unity/LayerProperties/VectorLayerProperties.cs @@ -48,5 +48,6 @@ public VectorSourceType sourceType public LayerPerformanceOptions performanceOptions; [NodeEditorElementAttribute("Vector Sublayers")] public List vectorSubLayers = new List(); + public List locationPrefabList = new List(); } } diff --git a/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs b/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs index 0e452a979..9152bba53 100644 --- a/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs +++ b/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs @@ -804,19 +804,7 @@ private void CreatePrefabLayer( PrefabItemOptions item ) _vectorData = new VectorLayer(); } - //ensure that there is a list of prefabitems - if (_vectorData.LocationPrefabsLayerProperties.locationPrefabList == null) - { - _vectorData.LocationPrefabsLayerProperties.locationPrefabList = new List(); - } - - //add the prefab item if it doesn't already exist - if (!_vectorData.LayerProperty.vectorSubLayers.Contains(item)) - { - _vectorData.LocationPrefabsLayerProperties.locationPrefabList.Add(item); - _vectorData.AddVectorLayer(item); - } - + _vectorData.AddLocationPrefabItem(item); } #endregion diff --git a/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs b/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs index 668276928..8f473783d 100644 --- a/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs +++ b/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs @@ -56,20 +56,32 @@ protected override void OnInitialized() DataFetcher.DataRecieved += OnVectorDataRecieved; DataFetcher.FetchingError += OnDataError; - foreach (var sublayer in _properties.vectorSubLayers) + foreach (var item in _properties.locationPrefabList) { - //if its of type prefabitemoptions then separate the visualizer type - LayerVisualizerBase visualizer; - if (typeof(PrefabItemOptions).IsAssignableFrom(sublayer.GetType())) //to check that the instance is of type PrefabItemOptions + LayerVisualizerBase visualizer = CreateInstance(); + ((LocationPrefabsLayerVisualizer)visualizer).SetProperties((PrefabItemOptions)item, _properties.performanceOptions); + + visualizer.Initialize(); + if (visualizer == null) { - visualizer = CreateInstance(); - ((LocationPrefabsLayerVisualizer)visualizer).SetProperties((PrefabItemOptions)sublayer, _properties.performanceOptions); + continue; + } + + if (_layerBuilder.ContainsKey(visualizer.Key)) + { + _layerBuilder[visualizer.Key].Add(visualizer); } else { - visualizer = CreateInstance(); - ((VectorLayerVisualizer)visualizer).SetProperties(sublayer, _properties.performanceOptions); + _layerBuilder.Add(visualizer.Key, new List() { visualizer }); } + } + + foreach (var sublayer in _properties.vectorSubLayers) + { + //if its of type prefabitemoptions then separate the visualizer type + LayerVisualizerBase visualizer = CreateInstance(); + ((VectorLayerVisualizer)visualizer).SetProperties(sublayer, _properties.performanceOptions); visualizer.Initialize(); if (visualizer == null) diff --git a/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs b/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs index 79f201da5..4b4641d8d 100644 --- a/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs +++ b/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs @@ -106,6 +106,32 @@ public void AddVectorLayer(VectorSubLayerProperties subLayerProperties) _layerProperty.vectorSubLayers.Add(subLayerProperties); } + public void AddLocationPrefabItem(PrefabItemOptions prefabItem) + { + //ensure that there is a list of prefabitems + if (LocationPrefabsLayerProperties.locationPrefabList == null) + { + LocationPrefabsLayerProperties.locationPrefabList = new List(); + } + + if(_layerProperty.locationPrefabList == null) + { + _layerProperty.locationPrefabList = new List(); + } + + //add the prefab item if it doesn't already exist + if (!LocationPrefabsLayerProperties.locationPrefabList.Contains(prefabItem)) + { + LocationPrefabsLayerProperties.locationPrefabList.Add(prefabItem); + } + + //add the prefab item if it doesn't already exist + if (!_layerProperty.locationPrefabList.Contains(prefabItem)) + { + _layerProperty.locationPrefabList.Add(prefabItem); + } + } + public void RemoveVectorLayer(int index) { if (_layerProperty.vectorSubLayers != null) @@ -114,6 +140,15 @@ public void RemoveVectorLayer(int index) } } + public void RemovePrefabItem(int index) + { + if (LocationPrefabsLayerProperties.locationPrefabList != null) + { + LocationPrefabsLayerProperties.locationPrefabList.RemoveAt(index); + } + } + + public void Initialize(LayerProperties properties) { _layerProperty = (VectorLayerProperties)properties; @@ -123,26 +158,18 @@ public void Initialize(LayerProperties properties) public void Initialize() { _vectorTileFactory = ScriptableObject.CreateInstance(); - if (_layerProperty.sourceType != VectorSourceType.None || _layerProperty.sourceOptions.Id.Contains(MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id)) - { - foreach (var item in _locationPrefabsLayerProperties.locationPrefabList) - { - //Add PrefabItemOptions items as a VectorSubLayerProperties - if (!_layerProperty.vectorSubLayers.Contains(item)) - { - //Add PrefabItemOptions items as a VectorSubLayerProperties - //if (_layerProperty.sourceType == VectorSourceType.Custom || _layerProperty.sourceType == VectorSourceType.None) - //{ - // if (_layerProperty.sourceType == VectorSourceType.None) - // _layerProperty.sourceOptions.Id = ""; - // //This is the style id we need for instantiating POI location prefabs - // Style streetsVectorSource = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets); - // AddLayerSource(streetsVectorSource.Id); - //} - AddVectorLayer(item); - } - } - } + //if (_layerProperty.sourceType != VectorSourceType.None || _layerProperty.sourceOptions.Id.Contains(MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id)) + //{ + // foreach (var item in _locationPrefabsLayerProperties.locationPrefabList) + // { + // //Add PrefabItemOptions items as a VectorSubLayerProperties + // if (!_layerProperty.vectorSubLayers.Contains(item)) + // { + // AddVectorLayer(item); + // } + // } + //} + _layerProperty.locationPrefabList = LocationPrefabsLayerProperties.locationPrefabList; _vectorTileFactory.SetOptions(_layerProperty); } From 613c9ac2d5cc8ee73909785eefe43300062510bd Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 4 May 2018 14:48:17 -0700 Subject: [PATCH 15/21] fixed indentation issues and checkboxes --- .../Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs | 1 + .../Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs | 2 -- .../Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs index 4eeb61d0f..4ca64fcaa 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs @@ -63,6 +63,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten GUILayout.Label(prefabLocationsTitle); //FindBy drop down + EditorGUI.indentLevel--; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(findByDropDown); var findByProp = property.FindPropertyRelative("findByType"); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 48b4970b3..906b55516 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -144,12 +144,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var layersRect = GUILayoutUtility.GetRect(0, 500, Mathf.Max(subLayerArray.arraySize + 1, 1) * _lineHeight, (subLayerArray.arraySize + 1) * _lineHeight); - layerTreeView.Layers = subLayerArray; layerTreeView.Reload(); layerTreeView.OnGUI(layersRect); - selectedLayers = layerTreeView.GetSelection(); //if there are selected elements, set the selection index at the first element. diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs index 9c66d62a0..2a24ad570 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs @@ -63,14 +63,15 @@ protected override void RenameEnded(RenameEndedArgs args) protected override void RowGUI (RowGUIArgs args) { + EditorGUI.indentLevel--; Rect toggleRect = args.rowRect; toggleRect.width = kToggleWidth; var item = Layers.GetArrayElementAtIndex(args.item.id); item.FindPropertyRelative("coreOptions.isActive").boolValue = EditorGUI.Toggle(toggleRect, item.FindPropertyRelative("coreOptions.isActive").boolValue); - args.rowRect.x += kToggleWidth; + //args.rowRect.x += kToggleWidth; args.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue; base.RowGUI(args); - + EditorGUI.indentLevel++; } } } From 866a01bf6876a5d00ab66f4fa7cba906512371bd Mon Sep 17 00:00:00 2001 From: jim-martin Date: Fri, 4 May 2018 17:38:07 -0700 Subject: [PATCH 16/21] add check for loaded tileJSON --- sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs | 3 +-- .../Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs index 624f4784d..564cfc9cd 100644 --- a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs @@ -52,6 +52,7 @@ public void ClearData() public void ProcessTileJSONData(TileJSONResponse tjr) { + tileJSONLoaded = true; List layerPropertiesList = new List(); List sourceLayersList = new List(); @@ -184,8 +185,6 @@ public void ProcessTileJSONData(TileJSONResponse tjr) } } } - - tileJSONLoaded = true; } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index f54787b3c..34a429593 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -150,7 +150,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { _isInitialized = true; } - if(tileJSONData.PropertyDisplayNames.Count==0) + if(tileJSONData.PropertyDisplayNames.Count==0 && tileJSONData.tileJSONLoaded) { EditorGUILayout.HelpBox("Invalid Map Id / There might be a problem with the internet connection.", MessageType.Error); } @@ -168,7 +168,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { _isInitialized = true; } - if (tileJSONData.PropertyDisplayNames.Count == 0) + if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded) { EditorGUILayout.HelpBox("Invalid Map Id / There might be a problem with the internet connection.", MessageType.Error); } From f467a2ceab22d318446e4b03573bae2c38cfc385 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 4 May 2018 17:47:00 -0700 Subject: [PATCH 17/21] added the new UI to the common area --- .../Mapbox/Unity/Editor/MapManagerEditor.cs | 103 ++++++++++++++++-- .../LayerPerformanceOptionsDrawer.cs | 3 +- .../LocationPrefabsLayerPropertiesDrawer.cs | 1 - .../PrefabItemOptionsDrawer.cs | 1 + .../VectorLayerPropertiesDrawer.cs | 90 +-------------- 5 files changed, 98 insertions(+), 100 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 21598b2d9..1bbb7af87 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -3,6 +3,7 @@ using UnityEngine; using UnityEditor; using Mapbox.Unity.Map; + using Mapbox.VectorTile.ExtensionMethods; [CustomEditor(typeof(AbstractMap))] [CanEditMultipleObjects] @@ -115,12 +116,27 @@ bool ShowPosition } } - private GUIContent _mapIdGui = new GUIContent + private GUIContent _requiredMapIdGui = new GUIContent { text = "Required Map Id", tooltip = "For location prefabs to spawn the \"streets-v7\" tileset needs to be a part of the Vector data source" }; + private GUIContent mapIdGui = new GUIContent + { + text = "Map Id", + tooltip = "Map Id corresponding to the tileset." + }; + + string CustomSourceMapId + { + get { return EditorPrefs.GetString("VectorLayerProperties_customSourceMapId"); } + set { EditorPrefs.SetString("VectorLayerProperties_customSourceMapId", value); } + } + + bool _isGUIContentSet = false; + GUIContent[] _sourceTypeContent; + public override void OnInspectorGUI() { serializedObject.Update(); @@ -156,23 +172,88 @@ public override void OnInspectorGUI() if (ShowMapLayers) { EditorGUI.indentLevel++; - ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST"); - if (ShowLocationPrefabs) + 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) { - var vectorDataProperty = serializedObject.FindProperty("_vectorData"); + _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); - var layerProperty = vectorDataProperty.FindPropertyRelative("_layerProperty"); - var layerSourceProperty = layerProperty.FindPropertyRelative("sourceOptions"); - var sourceType = layerProperty.FindPropertyRelative("_sourceType"); - VectorSourceType sourceTypeValue = (VectorSourceType)sourceType.enumValueIndex; - string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; - string layerString = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id").stringValue; + 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(_mapIdGui, streets_v7); + EditorGUILayout.TextField(_requiredMapIdGui, streets_v7); GUI.enabled = true; ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties"); } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs index d407e21e1..cdcffbd8e 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs @@ -8,7 +8,7 @@ public class LayerPerformanceOptionsDrawer : PropertyDrawer { static float lineHeight = EditorGUIUtility.singleLineHeight; - + static int checkBoxOffset = 15; SerializedProperty isActiveProperty; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) @@ -18,6 +18,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.BeginProperty(position, label, property); position.height = lineHeight; var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent("Enable Coroutines")); + typePosition.x -= checkBoxOffset; isActiveProperty.boolValue = EditorGUI.Toggle(typePosition, isActiveProperty.boolValue); if (isActiveProperty.boolValue == true) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs index 0ab75b84a..55c1b6595 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs @@ -32,7 +32,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.BeginProperty(position, label, property); position.height = _lineHeight; GUILayout.Space(-_lineHeight); - var prefabItemArray = property.FindPropertyRelative("locationPrefabList"); var layersRect = GUILayoutUtility.GetRect(0, 500, Mathf.Max(prefabItemArray.arraySize + 1, 1) * _lineHeight, (prefabItemArray.arraySize + 1) * _lineHeight); layerTreeView.Layers = prefabItemArray; diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs index 4ca64fcaa..c9bce3488 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs @@ -85,6 +85,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten default: break; } + EditorGUI.indentLevel++; EditorGUI.EndProperty(); } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 906b55516..588fb0ef5 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -15,8 +15,6 @@ public class VectorLayerPropertiesDrawer : PropertyDrawer { static float _lineHeight = EditorGUIUtility.singleLineHeight; - GUIContent[] _sourceTypeContent; - bool _isGUIContentSet = false; bool ShowPosition { @@ -36,18 +34,6 @@ int SelectionIndex set { EditorPrefs.SetInt("VectorLayerProperties_selectionIndex", value); } } - string CustomSourceMapId - { - get { return EditorPrefs.GetString("VectorLayerProperties_customSourceMapId"); } - set { EditorPrefs.SetString("VectorLayerProperties_customSourceMapId", value); } - } - - private GUIContent _mapIdGui = new GUIContent - { - text = "Map Id", - tooltip = "Map Id corresponding to the tileset." - }; - VectorSubLayerTreeView layerTreeView = new VectorSubLayerTreeView(new TreeViewState()); IList selectedLayers = new List(); @@ -56,84 +42,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.BeginProperty(position, label, property); position.height = _lineHeight; + GUILayout.Space(-_lineHeight); var sourceTypeProperty = property.FindPropertyRelative("_sourceType"); var sourceTypeValue = (VectorSourceType) sourceTypeProperty.enumValueIndex; - var displayNames = sourceTypeProperty.enumDisplayNames; - int count = sourceTypeProperty.enumDisplayNames.Length; - if (!_isGUIContentSet) - { - _sourceTypeContent = new GUIContent[count]; - for (int extIdx = 0; extIdx < count; extIdx++) - { - _sourceTypeContent[extIdx] = new GUIContent - { - text = displayNames[extIdx], - tooltip = ((VectorSourceType) extIdx).Description(), - }; - } - - _isGUIContentSet = true; - } - - var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent - { - text = "Data Source", - tooltip = "Source tileset for Vector Data" - }); - - sourceTypeProperty.enumValueIndex = - EditorGUI.Popup(typePosition, sourceTypeProperty.enumValueIndex, _sourceTypeContent); - sourceTypeValue = (VectorSourceType) sourceTypeProperty.enumValueIndex; - - position.y += _lineHeight; - var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); - var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); - var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); - var isActiveProperty = sourceOptionsProperty.FindPropertyRelative("isActive"); - switch (sourceTypeValue) - { - case VectorSourceType.MapboxStreets: - case VectorSourceType.MapboxStreetsWithBuildingIds: - var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue); - layerSourceId.stringValue = sourcePropertyValue.Id; - GUI.enabled = false; - EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); - GUI.enabled = true; - isActiveProperty.boolValue = true; - break; - case VectorSourceType.Custom: - layerSourceId.stringValue = CustomSourceMapId; - EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); - CustomSourceMapId = layerSourceId.stringValue; - isActiveProperty.boolValue = true; - break; - case VectorSourceType.None: - isActiveProperty.boolValue = false; - break; - default: - isActiveProperty.boolValue = false; - break; - } - if (sourceTypeValue != VectorSourceType.None) { - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - - var isStyleOptimized = property.FindPropertyRelative("useOptimizedStyle"); - EditorGUILayout.PropertyField(isStyleOptimized); - position.y += _lineHeight; - - if (isStyleOptimized.boolValue) - { - EditorGUILayout.PropertyField(property.FindPropertyRelative("optimizedStyle"), new GUIContent("Style Options")); - } - - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("optimizedStyle")); - EditorGUILayout.PropertyField(property.FindPropertyRelative("performanceOptions"), - new GUIContent("Perfomance Options")); - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("performanceOptions")); - EditorGUILayout.LabelField(new GUIContent { text = "Vector Layer Visualizers", @@ -278,6 +192,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty) { + EditorGUI.indentLevel--; var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); EditorGUI.indentLevel++; GUILayout.Label(subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties"); @@ -330,6 +245,7 @@ void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProper EditorGUI.indentLevel--; GUILayout.EndVertical(); EditorGUI.indentLevel--; + EditorGUI.indentLevel++; } void DrawModifiers(SerializedProperty property, GUIContent label) From 549f1e22d3c4e1d64bd73816e824d1483edcad95 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 4 May 2018 17:50:01 -0700 Subject: [PATCH 18/21] cosmetic changes done --- .../Assets/Mapbox/Unity/Editor/MapManagerEditor.cs | 2 +- .../Mapbox/Unity/Editor/VectorSubLayerTreeView.cs | 1 - .../Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs | 11 ----------- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index 1bbb7af87..e6df16b74 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -56,7 +56,7 @@ bool ShowTerrain } /// - /// Gets or sets a value show or hide Map Layers section show features. + /// Gets or sets a value to show or hide Map Layers section show features. /// /// true if show features; otherwise, false. bool ShowMapLayers diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs index 2a24ad570..e20612878 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs @@ -68,7 +68,6 @@ protected override void RowGUI (RowGUIArgs args) toggleRect.width = kToggleWidth; var item = Layers.GetArrayElementAtIndex(args.item.id); item.FindPropertyRelative("coreOptions.isActive").boolValue = EditorGUI.Toggle(toggleRect, item.FindPropertyRelative("coreOptions.isActive").boolValue); - //args.rowRect.x += kToggleWidth; args.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue; base.RowGUI(args); EditorGUI.indentLevel++; diff --git a/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs b/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs index 4b4641d8d..481400a09 100644 --- a/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs +++ b/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs @@ -158,17 +158,6 @@ public void Initialize(LayerProperties properties) public void Initialize() { _vectorTileFactory = ScriptableObject.CreateInstance(); - //if (_layerProperty.sourceType != VectorSourceType.None || _layerProperty.sourceOptions.Id.Contains(MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id)) - //{ - // foreach (var item in _locationPrefabsLayerProperties.locationPrefabList) - // { - // //Add PrefabItemOptions items as a VectorSubLayerProperties - // if (!_layerProperty.vectorSubLayers.Contains(item)) - // { - // AddVectorLayer(item); - // } - // } - //} _layerProperty.locationPrefabList = LocationPrefabsLayerProperties.locationPrefabList; _vectorTileFactory.SetOptions(_layerProperty); } From 5854e8558bee6fb32419e7bcf1b90be0533a0d53 Mon Sep 17 00:00:00 2001 From: Adarsh Pavani Date: Fri, 4 May 2018 18:17:31 -0700 Subject: [PATCH 19/21] adding formatting changes --- .../Unity/DataContainers/TileJsonData.cs | 28 +++++-------------- .../CoreVectorLayerPropertiesDrawer.cs | 3 -- .../GeometryExtrusionOptionsDrawer.cs | 14 +++------- .../VectorFilterOptionsDrawer.cs | 2 -- .../VectorLayerPropertiesDrawer.cs | 1 - .../Assets/Mapbox/Unity/Map/AbstractMap.cs | 1 - 6 files changed, 11 insertions(+), 38 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs index 564cfc9cd..f31241d18 100644 --- a/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs +++ b/sdkproject/Assets/Mapbox/Unity/DataContainers/TileJsonData.cs @@ -8,18 +8,18 @@ [Serializable] public class TileJsonData { - public readonly string commonLayersKey = "(layer found in more than one source)"; + public readonly string commonLayersKey = "(layer found in more than one data source)"; public readonly string optionalPropertiesString = "(may not appear across all locations)"; /// /// This boolean is to check if tile JSON data has loaded after the data source has changed /// public bool tileJSONLoaded = false; + /// /// Layer Display Names seen in the editor /// public List LayerDisplayNames = new List(); - /// /// Property Display Names seen in the editor /// @@ -97,31 +97,17 @@ public void ProcessTileJSONData(TileJSONResponse tjr) if (SourceLayersDictionary.ContainsKey(commonLayersKey)) { SourceLayersDictionary[commonLayersKey].Add(layerName); - if (LayerDisplayNames.Contains(layerName)) - { - LayerDisplayNames.Remove(layerName); - } - LayerDisplayNames.Add(layerName + " " + commonLayersKey); } else { SourceLayersDictionary.Add(commonLayersKey, new List() { layerName }); - if (LayerDisplayNames.Contains(layerName)) - { - LayerDisplayNames.Remove(layerName); - } - LayerDisplayNames.Add(layerName + " " + commonLayersKey); } - //remove the layer from other different sources - //foreach (var source in sourceList) - //{ - // SourceLayersDictionary[source].Remove(layerName); - - // //if the source contains zero layers remove th source from the list - // if (SourceLayersDictionary[source].Count == 0) - // SourceLayersDictionary.Remove(source); - //} + if (LayerDisplayNames.Contains(layerName)) + { + LayerDisplayNames.Remove(layerName); + } + LayerDisplayNames.Add(layerName + " " + commonLayersKey); } else { diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index be28db34f..0ed83781e 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -44,9 +44,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.indentLevel++; position.y += lineHeight; - //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("layerName")); var serializedMapObject = property.serializedObject; - //serializedMapObject.Update(); AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; tileJsonData = mapObject.VectorData.LayerProperty.tileJsonData; @@ -83,7 +81,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } EditorGUI.EndProperty(); - //serializedMapObject.ApplyModifiedProperties(); } private static int count = 0; private void DrawLayerName(SerializedProperty property,Rect position,List layerDisplayNames) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index 0eba25d4c..f96c0df18 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -76,7 +76,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; - //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); if (!dataUnavailable) { @@ -87,17 +86,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; - //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); if (!dataUnavailable) { position.y += 2.5f * lineHeight; - } break; + } + break; case Unity.Map.ExtrusionType.MaxHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; - //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); if (!dataUnavailable) { @@ -108,7 +106,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; - //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); DrawPropertyDropDown(property, position); if (!dataUnavailable) { @@ -120,7 +117,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), maxHeightProperty); if (minHeightProperty.floatValue > maxHeightProperty.floatValue) { - //position.y += lineHeight; EditorGUILayout.HelpBox("Maximum Height less than Minimum Height!", MessageType.Error); } break; @@ -133,7 +129,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten default: break; } - position.y += lineHeight; + + position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); EditorGUI.indentLevel--; @@ -146,7 +143,6 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) var selectedLayerName = property.FindPropertyRelative("_selectedLayerName").stringValue; var serializedMapObject = property.serializedObject; - //serializedMapObject.Update(); AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; tileJsonData = mapObject.VectorData.LayerProperty.tileJsonData; @@ -177,8 +173,6 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) _isInitialized = true; DrawPropertyName(property, position, propertyDisplayNames, selectedLayerName); } - - //serializedMapObject.ApplyModifiedProperties(); } private void DrawPropertyName(SerializedProperty property, Rect position, ListpropertyDisplayNames, string selectedLayerName) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs index 142a28766..1cc770f7c 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs @@ -61,7 +61,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibutton")) { propertyFilters.arraySize++; - //propertyFilters.GetArrayElementAtIndex(propertyFilters.arraySize - 1) = null; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; @@ -111,7 +110,6 @@ void DrawLayerFilter(SerializedProperty originalProperty, SerializedProperty pro EditorGUILayout.BeginHorizontal(); - //property.FindPropertyRelative("Key").stringValue = EditorGUILayout.TextField(property.FindPropertyRelative("Key").stringValue, GUILayout.MaxWidth(150)); var selectedLayerName = originalProperty.FindPropertyRelative("_selectedLayerName").stringValue; if (_isInitialized == true) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 34a429593..dd587d469 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -26,7 +26,6 @@ public class VectorLayerPropertiesDrawer : PropertyDrawer /// /// true then show general section; otherwise hide, false. - string objectId = ""; private string TilesetId { diff --git a/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs b/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs index b9cfd98be..14b8ccb30 100644 --- a/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs +++ b/sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs @@ -9,7 +9,6 @@ namespace Mapbox.Unity.Map using Mapbox.Map; using Mapbox.Unity.MeshGeneration.Factories; using Mapbox.Unity.MeshGeneration.Data; - using Mapbox.Platform.TilesetTileJSON; public interface IUnifiedMap { From eccfc52660a21b1df818a6c566d28d41a1b96717 Mon Sep 17 00:00:00 2001 From: Adarshkumar Pavani Date: Fri, 4 May 2018 18:27:57 -0700 Subject: [PATCH 20/21] Update 05-changelog.md Adding preloaded layers feature to the changelog --- documentation/docs/05-changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/docs/05-changelog.md b/documentation/docs/05-changelog.md index dd3a4c24e..c12454ff5 100644 --- a/documentation/docs/05-changelog.md +++ b/documentation/docs/05-changelog.md @@ -1,6 +1,7 @@ ## CHANGELOG ### v.1.4.2 *??/??/2018* +- Layer names and property names are preloaded from the data source into a dropdown. ##### New Features - Add `OnUpdated` event to `AbstractMap`. Enables subscribers to get a notification when the map location and/or zoom gets updated. From 110476c32457f129032a3ef0d16f87224ffdde90 Mon Sep 17 00:00:00 2001 From: Abhishek Tripathi Date: Sat, 5 May 2018 21:57:50 -0700 Subject: [PATCH 21/21] Switch to EditorGuiLayout and some UI formatting changes. --- .../Unity/Editor/GeocodeAttributeDrawer.cs | 18 +- .../Mapbox/Unity/Editor/MapManagerEditor.cs | 216 +++++++------ .../CameraBoundsTileProviderOptionsDrawer.cs | 18 +- .../PropertyDrawers/ColliderOptionsDrawer.cs | 37 ++- .../CoreVectorLayerPropertiesDrawer.cs | 62 ++-- .../ElevationLayerPropertiesDrawer.cs | 57 +--- .../GeometryExtrusionOptionsDrawer.cs | 92 ++---- .../GeometryMaterialOptionsDrawer.cs | 4 +- .../ImageryLayerPropertiesDrawer.cs | 40 +-- .../LayerPerformanceOptionsDrawer.cs | 51 +-- .../LocationPrefabsLayerPropertiesDrawer.cs | 295 +++++++++--------- .../PropertyDrawers/MapExtentOptionsDrawer.cs | 55 +--- .../MapLocationOptionsDrawer.cs | 23 +- .../MapPlacementOptionsDrawer.cs | 17 +- .../MapScalingOptionsDrawer.cs | 21 +- .../PrefabItemOptionsDrawer.cs | 94 +++--- ...roundTransformTileProviderOptionsDrawer.cs | 6 +- .../RangeTileProviderOptionsDrawer.cs | 6 +- .../SpawnPrefabOptionsDrawer.cs | 78 +++-- .../PropertyDrawers/StyleOptionsDrawer.cs | 9 +- .../VectorLayerPropertiesDrawer.cs | 65 ++-- .../Unity/Editor/VectorSubLayerTreeView.cs | 8 +- 22 files changed, 537 insertions(+), 735 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs index 8b91fe6e8..51e7d07f2 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs @@ -16,17 +16,21 @@ public class GeocodeAttributeDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - float buttonWidth = EditorGUIUtility.singleLineHeight * 4; - - Rect fieldRect = new Rect(position.x, position.y, position.width - buttonWidth, EditorGUIUtility.singleLineHeight); - Rect buttonRect = new Rect(position.x + position.width - buttonWidth, position.y, buttonWidth, EditorGUIUtility.singleLineHeight); - - EditorGUI.PropertyField(fieldRect, property); + GUILayout.BeginHorizontal(); + if (string.IsNullOrEmpty(label.text)) + { - if (GUI.Button(buttonRect, searchButtonContent)) + property.stringValue = EditorGUILayout.TextField(property.stringValue); + } + else + { + property.stringValue = EditorGUILayout.TextField(label, property.stringValue); + } + if (GUILayout.Button(new GUIContent(searchButtonContent), (GUIStyle)"minibutton", GUILayout.MaxWidth(100))) { GeocodeAttributeSearchWindow.Open(property); } + GUILayout.EndHorizontal(); } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs index e6df16b74..2152ed0ee 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -136,25 +136,26 @@ string CustomSourceMapId bool _isGUIContentSet = false; GUIContent[] _sourceTypeContent; + static float _lineHeight = EditorGUIUtility.singleLineHeight; public override void OnInspectorGUI() { serializedObject.Update(); - GUILayout.BeginVertical(); + EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); ShowGeneral = EditorGUILayout.Foldout(ShowGeneral, new GUIContent { text = "GENERAL", tooltip = "Options related to map data" }); + if (ShowGeneral) { - EditorGUILayout.Space(); DrawMapOptions(serializedObject); } - ShowSepartor(); ShowImage = EditorGUILayout.Foldout(ShowImage, "IMAGE"); if (ShowImage) { + GUILayout.Space(-1.5f * _lineHeight); ShowSection(serializedObject.FindProperty("_imagery"), "_layerProperty"); } @@ -163,6 +164,7 @@ public override void OnInspectorGUI() ShowTerrain = EditorGUILayout.Foldout(ShowTerrain, "TERRAIN"); if (ShowTerrain) { + GUILayout.Space(-1.5f * _lineHeight); ShowSection(serializedObject.FindProperty("_terrain"), "_layerProperty"); } @@ -171,104 +173,8 @@ 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 in the FEATURES section.", MessageType.Error); - } - } - ShowSepartor(); - ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES"); - if (ShowFeatures) - { - ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); - } - EditorGUI.indentLevel--; + DrawMapLayerOptions(); + //EditorGUI.indentLevel--; } GUILayout.EndVertical(); @@ -291,19 +197,22 @@ void DrawMapOptions(SerializedObject mapObject) { var property = mapObject.FindProperty("_options"); - EditorGUILayout.LabelField("Location "); + EditorGUILayout.LabelField("Location ", GUILayout.Height(_lineHeight)); + EditorGUILayout.PropertyField(property.FindPropertyRelative("locationOptions")); var extentOptions = property.FindPropertyRelative("extentOptions"); var extentOptionsType = extentOptions.FindPropertyRelative("extentType"); if ((MapExtentType)extentOptionsType.enumValueIndex == MapExtentType.Custom) { - var test = mapObject.FindProperty("_tileProvider"); EditorGUILayout.PropertyField(extentOptionsType); + EditorGUI.indentLevel++; EditorGUILayout.PropertyField(test); + EditorGUI.indentLevel--; } else { + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(property.FindPropertyRelative("extentOptions")); } @@ -312,12 +221,113 @@ void DrawMapOptions(SerializedObject mapObject) ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others"); if (ShowPosition) { + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(property.FindPropertyRelative("placementOptions")); + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(property.FindPropertyRelative("scalingOptions")); EditorGUILayout.PropertyField(property.FindPropertyRelative("loadingTexture")); } } + void DrawMapLayerOptions() + { + //EditorGUI.indentLevel++; + var vectorDataProperty = serializedObject.FindProperty("_vectorData"); + var layerProperty = vectorDataProperty.FindPropertyRelative("_layerProperty"); + var layerSourceProperty = layerProperty.FindPropertyRelative("sourceOptions"); + var sourceTypeProperty = layerProperty.FindPropertyRelative("_sourceType"); + VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; + string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; + var layerSourceId = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id"); + string layerString = layerSourceId.stringValue; + var isActiveProperty = layerSourceProperty.FindPropertyRelative("isActive"); + + var displayNames = sourceTypeProperty.enumDisplayNames; + int count = sourceTypeProperty.enumDisplayNames.Length; + if (!_isGUIContentSet) + { + _sourceTypeContent = new GUIContent[count]; + for (int extIdx = 0; extIdx < count; extIdx++) + { + _sourceTypeContent[extIdx] = new GUIContent + { + text = displayNames[extIdx], + tooltip = ((VectorSourceType)extIdx).Description(), + }; + } + + _isGUIContentSet = true; + } + + sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(new GUIContent + { + text = "Data Source", + tooltip = "Source tileset for Vector Data" + }, sourceTypeProperty.enumValueIndex, _sourceTypeContent); + + sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; + + switch (sourceTypeValue) + { + case VectorSourceType.MapboxStreets: + case VectorSourceType.MapboxStreetsWithBuildingIds: + var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue); + layerSourceId.stringValue = sourcePropertyValue.Id; + GUI.enabled = false; + EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui); + GUI.enabled = true; + isActiveProperty.boolValue = true; + break; + case VectorSourceType.Custom: + layerSourceId.stringValue = CustomSourceMapId; + EditorGUILayout.PropertyField(layerSourceProperty, mapIdGui); + CustomSourceMapId = layerSourceId.stringValue; + isActiveProperty.boolValue = true; + break; + case VectorSourceType.None: + isActiveProperty.boolValue = false; + break; + default: + isActiveProperty.boolValue = false; + break; + } + + if (sourceTypeValue != VectorSourceType.None) + { + var isStyleOptimized = layerProperty.FindPropertyRelative("useOptimizedStyle"); + EditorGUILayout.PropertyField(isStyleOptimized); + + if (isStyleOptimized.boolValue) + { + EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("optimizedStyle"), new GUIContent("Style Options")); + } + GUILayout.Space(-_lineHeight); + EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("performanceOptions"), new GUIContent("Perfomance Options")); + } + EditorGUILayout.Space(); + ShowSepartor(); + ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST"); + if (ShowLocationPrefabs) + { + if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7)) + { + GUI.enabled = false; + EditorGUILayout.TextField(_requiredMapIdGui, streets_v7); + GUI.enabled = true; + ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties"); + } + else + { + EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source in the FEATURES section.", MessageType.Error); + } + } + ShowSepartor(); + ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES"); + if (ShowFeatures) + { + ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); + } + } void PresetLocationBased(SerializedProperty unifiedMap) { //Set diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CameraBoundsTileProviderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CameraBoundsTileProviderOptionsDrawer.cs index cc4858531..b69eb9548 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CameraBoundsTileProviderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CameraBoundsTileProviderOptionsDrawer.cs @@ -7,16 +7,22 @@ [CustomPropertyDrawer(typeof(CameraBoundsTileProviderOptions))] public class CameraBoundsTileProviderOptionsDrawer : PropertyDrawer { - static float lineHeight = EditorGUIUtility.singleLineHeight; + static float _lineHeight = EditorGUIUtility.singleLineHeight; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); var camera = property.FindPropertyRelative("camera"); var updateInterval = property.FindPropertyRelative("updateInterval"); - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), camera, new GUIContent { text = camera.displayName, tooltip = "Camera to control map extent." }); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), updateInterval, new GUIContent { text = updateInterval.displayName, tooltip = "Time in ms between map extent update." }); - EditorGUI.EndProperty(); + EditorGUILayout.PropertyField(camera, new GUIContent + { + text = camera.displayName, + tooltip = "Camera to control map extent." + }, GUILayout.Height(_lineHeight)); + EditorGUILayout.PropertyField(updateInterval, new GUIContent + { + text = updateInterval.displayName, + tooltip = "Time in ms between map extent update." + }, GUILayout.Height(_lineHeight)); + } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs index 4b57b213f..215a84363 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs @@ -11,28 +11,35 @@ public class ColliderOptionsDrawer : PropertyDrawer { static float lineHeight = EditorGUIUtility.singleLineHeight; + bool isGUIContentSet = false; + GUIContent[] colliderTypeContent; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Collider Type", tooltip = "The type of collider added to game objects in this layer." }); + var colliderTypeLabel = new GUIContent + { + text = "Collider Type", + tooltip = "The type of collider added to game objects in this layer." + }; var colliderTypeProperty = property.FindPropertyRelative("colliderType"); - List enumContent = new List(); - foreach(var enumValue in colliderTypeProperty.enumDisplayNames) + var displayNames = colliderTypeProperty.enumDisplayNames; + int count = colliderTypeProperty.enumDisplayNames.Length; + + if (!isGUIContentSet) { - var guiContent = new GUIContent { text = enumValue, tooltip = ((Unity.Map.ColliderType)colliderTypeProperty.enumValueIndex).Description()} ; - enumContent.Add(guiContent); + colliderTypeContent = new GUIContent[count]; + for (int extIdx = 0; extIdx < count; extIdx++) + { + colliderTypeContent[extIdx] = new GUIContent + { + text = displayNames[extIdx], + tooltip = EnumExtensions.Description((ColliderType)extIdx), + }; + } + isGUIContentSet = true; } - EditorGUI.indentLevel--; - colliderTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, colliderTypeProperty.enumValueIndex, enumContent.ToArray()); - EditorGUI.indentLevel++; - EditorGUI.EndProperty(); - } - - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - return lineHeight; + colliderTypeProperty.enumValueIndex = EditorGUILayout.Popup(colliderTypeLabel, colliderTypeProperty.enumValueIndex, colliderTypeContent); } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index e38dc4d18..5bac41edb 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -3,57 +3,53 @@ using UnityEditor; using UnityEngine; using Mapbox.Unity.Map; + using Mapbox.VectorTile.ExtensionMethods; [CustomPropertyDrawer(typeof(CoreVectorLayerProperties))] public class CoreVectorLayerPropertiesDrawer : PropertyDrawer { static float lineHeight = EditorGUIUtility.singleLineHeight; + bool isGUIContentSet = false; + GUIContent[] primitiveTypeContent; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - // Draw label. var primitiveType = property.FindPropertyRelative("geometryType"); - var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Primitive Type", tooltip = "Primitive geometry type of the visualizer, allowed primitives - point, line, polygon." }); - EditorGUI.indentLevel--; - primitiveType.enumValueIndex = EditorGUI.Popup(typePosition, primitiveType.enumValueIndex, primitiveType.enumDisplayNames); - EditorGUI.indentLevel++; - - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("layerName")); - - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("snapToTerrain")); + var primitiveTypeLabel = new GUIContent + { + text = "Primitive Type", + tooltip = "Primitive geometry type of the visualizer, allowed primitives - point, line, polygon." + }; - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("groupFeatures")); + var displayNames = primitiveType.enumDisplayNames; + int count = primitiveType.enumDisplayNames.Length; - if ((VectorPrimitiveType)primitiveType.enumValueIndex == VectorPrimitiveType.Line) + if (!isGUIContentSet) { - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("lineWidth")); + primitiveTypeContent = new GUIContent[count]; + for (int extIdx = 0; extIdx < count; extIdx++) + { + primitiveTypeContent[extIdx] = new GUIContent + { + text = displayNames[extIdx], + tooltip = EnumExtensions.Description((VectorPrimitiveType)extIdx), + }; + } + isGUIContentSet = true; } + primitiveType.enumValueIndex = EditorGUILayout.Popup(primitiveTypeLabel, primitiveType.enumValueIndex, primitiveTypeContent); - EditorGUI.EndProperty(); - } + EditorGUILayout.PropertyField(property.FindPropertyRelative("layerName")); - /// - /// Gets the number of UI rows necessary to draw the property correctly, given it's primitive type. - /// - /// The property height. - /// Property. - /// Label. - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var sourceTypeProperty = property.FindPropertyRelative("geometryType"); - - float height = 0.0f; - height += (((((VectorPrimitiveType)sourceTypeProperty.enumValueIndex == VectorPrimitiveType.Line)) ? 5.0f : 4.0f) * EditorGUIUtility.singleLineHeight); + EditorGUILayout.PropertyField(property.FindPropertyRelative("snapToTerrain")); + EditorGUILayout.PropertyField(property.FindPropertyRelative("groupFeatures")); - return height; + if ((VectorPrimitiveType)primitiveType.enumValueIndex == VectorPrimitiveType.Line) + { + EditorGUILayout.PropertyField(property.FindPropertyRelative("lineWidth")); + } } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs index c73d7b001..cd884cee7 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs @@ -44,9 +44,6 @@ string CustomSourceMapId public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (ElevationSourceType)sourceTypeProperty.enumValueIndex; @@ -65,13 +62,11 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } isGUIContentSet = true; } - var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Data Source", tooltip = "Source tileset for Terrain." }); + var sourceTypeLabel = new GUIContent { text = "Data Source", tooltip = "Source tileset for Terrain." }; - sourceTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, sourceTypeProperty.enumValueIndex, sourceTypeContent); + sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent); sourceTypeValue = (ElevationSourceType)sourceTypeProperty.enumValueIndex; - position.y += lineHeight; - var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); @@ -81,12 +76,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var sourcePropertyValue = MapboxDefaultElevation.GetParameters(sourceTypeValue); layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; - EditorGUI.PropertyField(position, sourceOptionsProperty, _mapIdGui); + EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); GUI.enabled = true; break; case ElevationSourceType.Custom: layerSourceId.stringValue = CustomSourceMapId; - EditorGUI.PropertyField(position, sourceOptionsProperty, _mapIdGui); + EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); CustomSourceMapId = layerSourceId.stringValue; break; default: @@ -95,54 +90,32 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten //EditorGUI.PropertyField(position, property.FindPropertyRelative("sourceOptions"), true); - if (sourceTypeValue != ElevationSourceType.None) - { - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - } + //if (sourceTypeValue != ElevationSourceType.None) + //{ + // position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); + //} if (sourceTypeValue == ElevationSourceType.None) { GUI.enabled = false; } var elevationLayerType = property.FindPropertyRelative("elevationLayerType"); - EditorGUI.PropertyField(position, elevationLayerType, new GUIContent { text = elevationLayerType.displayName, tooltip = ((ElevationLayerType)elevationLayerType.enumValueIndex).Description() }); + EditorGUILayout.PropertyField(elevationLayerType, new GUIContent { text = elevationLayerType.displayName, tooltip = ((ElevationLayerType)elevationLayerType.enumValueIndex).Description() }); position.y += lineHeight; if (sourceTypeValue == ElevationSourceType.None) { GUI.enabled = true; } - EditorGUI.PropertyField(position, property.FindPropertyRelative("requiredOptions"), true); - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("requiredOptions")); - ShowPosition = EditorGUI.Foldout(position, ShowPosition, "Others"); + EditorGUILayout.PropertyField(property.FindPropertyRelative("requiredOptions"), true); + //position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("requiredOptions")); + ShowPosition = EditorGUILayout.Foldout(ShowPosition, "Others"); if (ShowPosition) { - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("modificationOptions"), true); - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("modificationOptions")); - EditorGUI.PropertyField(position, property.FindPropertyRelative("sideWallOptions"), true); - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sideWallOptions")); - EditorGUI.PropertyField(position, property.FindPropertyRelative("unityLayerOptions"), true); + EditorGUILayout.PropertyField(property.FindPropertyRelative("modificationOptions"), true); + EditorGUILayout.PropertyField(property.FindPropertyRelative("sideWallOptions"), true); + EditorGUILayout.PropertyField(property.FindPropertyRelative("unityLayerOptions"), true); } - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); - var sourceTypeValue = (ElevationSourceType)sourceTypeProperty.enumValueIndex; - - float height = ((sourceTypeValue == ElevationSourceType.None) ? 2.0f : 3.0f) * lineHeight; - - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("requiredOptions")); - if (ShowPosition) - { - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("modificationOptions")); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("unityLayerOptions")); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sideWallOptions")); - } - return height; } } - } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index a8097f9b2..338d23c15 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -9,22 +9,21 @@ public class GeometryExtrusionOptionsDrawer : PropertyDrawer { static float lineHeight = EditorGUIUtility.singleLineHeight; - GUIContent[] sourceTypeContent; + GUIContent[] extrusionTypeContent; bool isGUIContentSet = false; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); var extrusionTypeProperty = property.FindPropertyRelative("extrusionType"); - var displayNames = extrusionTypeProperty.enumDisplayNames; int count = extrusionTypeProperty.enumDisplayNames.Length; + if (!isGUIContentSet) { - sourceTypeContent = new GUIContent[count]; + extrusionTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { - sourceTypeContent[extIdx] = new GUIContent + extrusionTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((ExtrusionType)extIdx), @@ -33,12 +32,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten isGUIContentSet = true; } - var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Extrusion Type", tooltip = "Type of geometry extrusion" }); + var extrusionTypeLabel = new GUIContent + { + text = "Extrusion Type", + tooltip = "Type of geometry extrusion" + }; + extrusionTypeProperty.enumValueIndex = EditorGUILayout.Popup(extrusionTypeLabel, extrusionTypeProperty.enumValueIndex, extrusionTypeContent); - EditorGUI.indentLevel--; - extrusionTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, extrusionTypeProperty.enumValueIndex, sourceTypeContent); - EditorGUI.indentLevel++; var sourceTypeValue = (Unity.Map.ExtrusionType)extrusionTypeProperty.enumValueIndex; var minHeightProperty = property.FindPropertyRelative("minimumHeight"); @@ -52,83 +53,36 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten case Unity.Map.ExtrusionType.None: break; case Unity.Map.ExtrusionType.PropertyHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.MinHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.MaxHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.RangeHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), minHeightProperty); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), maxHeightProperty); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(property.FindPropertyRelative("propertyName")); + EditorGUILayout.PropertyField(minHeightProperty); + EditorGUILayout.PropertyField(maxHeightProperty); if (minHeightProperty.floatValue > maxHeightProperty.floatValue) { - //position.y += lineHeight; EditorGUILayout.HelpBox("Maximum Height less than Minimum Height!", MessageType.Error); } break; case Unity.Map.ExtrusionType.AbsoluteHeight: - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), maxHeightProperty, new GUIContent { text = "Height" }); + EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); + EditorGUILayout.PropertyField(maxHeightProperty, new GUIContent { text = "Height" }); break; default: break; } - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); + EditorGUILayout.PropertyField(property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); EditorGUI.indentLevel--; - - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var extrusionTypeProperty = property.FindPropertyRelative("extrusionType"); - var sourceTypeValue = (Unity.Map.ExtrusionType)extrusionTypeProperty.enumValueIndex; - - int rows = 1; - //if (showPosition) - { - switch (sourceTypeValue) - { - case Unity.Map.ExtrusionType.None: - rows += 1; - break; - case Unity.Map.ExtrusionType.PropertyHeight: - case Unity.Map.ExtrusionType.MinHeight: - case Unity.Map.ExtrusionType.MaxHeight: - rows += 3; - break; - case Unity.Map.ExtrusionType.RangeHeight: - rows += 5; - break; - case Unity.Map.ExtrusionType.AbsoluteHeight: - rows += 3; - break; - default: - rows += 2; - break; - } - } - return (float)rows * lineHeight; } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryMaterialOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryMaterialOptionsDrawer.cs index f2365c449..5500fd7c3 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryMaterialOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryMaterialOptionsDrawer.cs @@ -22,9 +22,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Texturing Type", tooltip = "Use image texture from the Imagery source as texture for roofs. " }); var texturingType = property.FindPropertyRelative("texturingType"); EditorGUI.indentLevel--; - EditorGUI.indentLevel--; + texturingType.enumValueIndex = EditorGUI.Popup(typePosition, texturingType.enumValueIndex, texturingType.enumDisplayNames); - EditorGUI.indentLevel++; + EditorGUI.indentLevel++; var matList = property.FindPropertyRelative("materials"); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs index 28b5678ad..881df8b75 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ImageryLayerPropertiesDrawer.cs @@ -33,9 +33,6 @@ string CustomSourceMapId public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; @@ -49,19 +46,18 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten sourceTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], - tooltip = ((ImagerySourceType)extIdx).Description(), + tooltip = EnumExtensions.Description((ImagerySourceType)extIdx), }; } isGUIContentSet = true; } - // Draw label. - var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Data Source", tooltip = "Source tileset for Imagery." }); + // Draw label. + var sourceTypeLabel = new GUIContent { text = "Data Source", tooltip = "Source tileset for Imagery." }; - sourceTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, sourceTypeProperty.enumValueIndex, sourceTypeContent); + sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent); sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; - position.y += lineHeight; var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); @@ -77,12 +73,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var sourcePropertyValue = MapboxDefaultImagery.GetParameters(sourceTypeValue); layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; - EditorGUI.PropertyField(position, sourceOptionsProperty,_mapIdGui); + EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); GUI.enabled = true; break; case ImagerySourceType.Custom: layerSourceId.stringValue = CustomSourceMapId; - EditorGUI.PropertyField(position, sourceOptionsProperty, new GUIContent{text = "Map Id / Style URL", tooltip = _mapIdGui.tooltip} ); + EditorGUILayout.PropertyField(sourceOptionsProperty, new GUIContent { text = "Map Id / Style URL", tooltip = _mapIdGui.tooltip }); CustomSourceMapId = layerSourceId.stringValue; break; case ImagerySourceType.None: @@ -92,29 +88,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } if (sourceTypeValue != ImagerySourceType.None) { - position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - EditorGUI.PropertyField(position, property.FindPropertyRelative("rasterOptions")); - } - - EditorGUI.EndProperty(); - - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var sourceTypeProperty = property.FindPropertyRelative("sourceType"); - var sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; - - if (sourceTypeValue == ImagerySourceType.None) - { - return lineHeight; - } - else - { - float height = 0.0f; - height += (1.0f * lineHeight); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("rasterOptions")); - height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); - return height; + EditorGUILayout.PropertyField(property.FindPropertyRelative("rasterOptions")); } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs index cdcffbd8e..b229b36bf 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LayerPerformanceOptionsDrawer.cs @@ -15,61 +15,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { isActiveProperty = property.FindPropertyRelative("isEnabled"); - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent("Enable Coroutines")); - typePosition.x -= checkBoxOffset; - isActiveProperty.boolValue = EditorGUI.Toggle(typePosition, isActiveProperty.boolValue); + isActiveProperty.boolValue = EditorGUILayout.Toggle(new GUIContent("Enable Coroutines"), isActiveProperty.boolValue); if (isActiveProperty.boolValue == true) { EditorGUI.indentLevel++; - position.y += lineHeight; - EditorGUI.PropertyField(position, property.FindPropertyRelative("entityPerCoroutine"), true); + EditorGUILayout.PropertyField(property.FindPropertyRelative("entityPerCoroutine"), true); EditorGUI.indentLevel--; } - - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - float height = 0.0f; - if (isActiveProperty != null && isActiveProperty.boolValue == true) - { - height += (2.0f * EditorGUIUtility.singleLineHeight); - //height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("layerSource"), false); - } - else - { - height = EditorGUIUtility.singleLineHeight; - } - - return height; } } - - //[CustomPropertyDrawer(typeof(TypeVisualizerTuple))] - //public class TypeVisualizerBaseDrawer : PropertyDrawer - //{ - // static float lineHeight = EditorGUIUtility.singleLineHeight; - // bool showPosition = true; - // public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - // { - // EditorGUI.BeginProperty(position, label, property); - - // position.height = lineHeight; - - // EditorGUI.PropertyField(position, property.FindPropertyRelative("Stack")); - - // EditorGUI.EndProperty(); - // } - // public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - // { - // // Reserve space for the total visible properties. - // int rows = 2; - // //Debug.Log("Height - " + rows * lineHeight); - // return (float)rows * lineHeight; - // } - //} - } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs index 55c1b6595..40d6e1ea9 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs @@ -1,150 +1,145 @@ -namespace Mapbox.Unity.Map -{ - using UnityEngine; - using System.Collections.Generic; - using UnityEditor; - using Mapbox.Editor; - using UnityEditor.IMGUI.Controls; - using System.Linq; - - [CustomPropertyDrawer(typeof(LocationPrefabsLayerProperties))] - public class LocationPrefabsLayerPropertiesDrawer : PropertyDrawer - { - static float _lineHeight = EditorGUIUtility.singleLineHeight; - - VectorSubLayerTreeView layerTreeView = new VectorSubLayerTreeView(new TreeViewState()); - IList selectedLayers = new List(); - - int SelectionIndex - { - get - { - return EditorPrefs.GetInt("LocationPrefabsLayerProperties_selectionIndex"); - } - set - { - EditorPrefs.SetInt("LocationPrefabsLayerProperties_selectionIndex", value); - } - } - - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - EditorGUI.BeginProperty(position, label, property); - position.height = _lineHeight; - GUILayout.Space(-_lineHeight); - var prefabItemArray = property.FindPropertyRelative("locationPrefabList"); - var layersRect = GUILayoutUtility.GetRect(0, 500, Mathf.Max(prefabItemArray.arraySize + 1, 1) * _lineHeight, (prefabItemArray.arraySize + 1) * _lineHeight); - layerTreeView.Layers = prefabItemArray; - layerTreeView.Reload(); - layerTreeView.OnGUI(layersRect); - - selectedLayers = layerTreeView.GetSelection(); - //if there are selected elements, set the selection index at the first element. - //if not, use the Selection index to persist the selection at the right index. - if (selectedLayers.Count > 0) - { - //ensure that selectedLayers[0] isn't out of bounds - if (selectedLayers[0] > prefabItemArray.arraySize - 1) - { - selectedLayers[0] = prefabItemArray.arraySize - 1; - } - - SelectionIndex = selectedLayers[0]; - - } - else - { - selectedLayers = new int[1] { SelectionIndex }; - if (SelectionIndex > 0 && (SelectionIndex <= prefabItemArray.arraySize - 1)) - { - layerTreeView.SetSelection(selectedLayers); - } - } - - - GUILayout.Space(EditorGUIUtility.singleLineHeight); - GUILayout.BeginHorizontal(); - - if (GUILayout.Button(new GUIContent("Add Layer"), (GUIStyle)"minibuttonleft")) - { - - GUILayout.Space(EditorGUIUtility.singleLineHeight); - - selectedLayers = layerTreeView.GetSelection(); - - prefabItemArray.arraySize++; - - var prefabItem = prefabItemArray.GetArrayElementAtIndex(prefabItemArray.arraySize - 1); - var prefabItemName = prefabItem.FindPropertyRelative("coreOptions.sublayerName"); - - prefabItemName.stringValue = "New Location"; - - // Set defaults here because SerializedProperty copies the previous element. - prefabItem.FindPropertyRelative("coreOptions.isActive").boolValue = true; - prefabItem.FindPropertyRelative("coreOptions.snapToTerrain").boolValue = true; - var categories = prefabItem.FindPropertyRelative("categories"); - categories.intValue = (int)(LocationPrefabCategories.AnyCategory);//To select any category option - - var density = prefabItem.FindPropertyRelative("density"); - density.intValue = 15;//To select all locations option - - selectedLayers = new int[1] { prefabItemArray.arraySize - 1 }; - layerTreeView.SetSelection(selectedLayers); - - - } - if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright")) - { - foreach (var index in selectedLayers.OrderByDescending(i => i)) - { - prefabItemArray.DeleteArrayElementAtIndex(index); - } - selectedLayers = new int[0]; - layerTreeView.SetSelection(selectedLayers); - } - - GUILayout.EndHorizontal(); - - if (selectedLayers.Count == 1 && prefabItemArray.arraySize != 0) - { - //ensure that selectedLayers[0] isn't out of bounds - if (selectedLayers[0] > prefabItemArray.arraySize - 1) - { - selectedLayers[0] = prefabItemArray.arraySize - 1; - } - SelectionIndex = selectedLayers[0]; - - var layerProperty = prefabItemArray.GetArrayElementAtIndex(SelectionIndex); - - layerProperty.isExpanded = true; - var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); - bool isLayerActive = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue; - if (!isLayerActive) - { - GUI.enabled = false; - } - - DrawLayerLocationPrefabProperties( layerProperty); - if (!isLayerActive) - { - GUI.enabled = true; - } - } - else - { - GUILayout.Space(15); - GUILayout.Label("Select a visualizer to see properties"); - } - - EditorGUI.EndProperty(); - } - - - void DrawLayerLocationPrefabProperties(SerializedProperty layerProperty) - { - EditorGUI.indentLevel++; - EditorGUILayout.PropertyField(layerProperty); - EditorGUI.indentLevel--; - } - } -} +namespace Mapbox.Unity.Map +{ + using UnityEngine; + using System.Collections.Generic; + using UnityEditor; + using Mapbox.Editor; + using UnityEditor.IMGUI.Controls; + using System.Linq; + + [CustomPropertyDrawer(typeof(LocationPrefabsLayerProperties))] + public class LocationPrefabsLayerPropertiesDrawer : PropertyDrawer + { + static float _lineHeight = EditorGUIUtility.singleLineHeight; + + VectorSubLayerTreeView layerTreeView = new VectorSubLayerTreeView(new TreeViewState()); + IList selectedLayers = new List(); + + int SelectionIndex + { + get + { + return EditorPrefs.GetInt("LocationPrefabsLayerProperties_selectionIndex"); + } + set + { + EditorPrefs.SetInt("LocationPrefabsLayerProperties_selectionIndex", value); + } + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + GUILayout.Space(-_lineHeight); + var prefabItemArray = property.FindPropertyRelative("locationPrefabList"); + var layersRect = GUILayoutUtility.GetRect(0, 500, Mathf.Max(prefabItemArray.arraySize + 1, 1) * _lineHeight, (prefabItemArray.arraySize + 1) * _lineHeight); + + layerTreeView.Layers = prefabItemArray; + layerTreeView.Reload(); + layerTreeView.OnGUI(layersRect); + + selectedLayers = layerTreeView.GetSelection(); + //if there are selected elements, set the selection index at the first element. + //if not, use the Selection index to persist the selection at the right index. + if (selectedLayers.Count > 0) + { + //ensure that selectedLayers[0] isn't out of bounds + if (selectedLayers[0] > prefabItemArray.arraySize - 1) + { + selectedLayers[0] = prefabItemArray.arraySize - 1; + } + + SelectionIndex = selectedLayers[0]; + + } + else + { + selectedLayers = new int[1] { SelectionIndex }; + if (SelectionIndex > 0 && (SelectionIndex <= prefabItemArray.arraySize - 1)) + { + layerTreeView.SetSelection(selectedLayers); + } + } + + + GUILayout.Space(EditorGUIUtility.singleLineHeight); + GUILayout.BeginHorizontal(); + + if (GUILayout.Button(new GUIContent("Add Layer"), (GUIStyle)"minibuttonleft")) + { + + GUILayout.Space(EditorGUIUtility.singleLineHeight); + + selectedLayers = layerTreeView.GetSelection(); + + prefabItemArray.arraySize++; + + var prefabItem = prefabItemArray.GetArrayElementAtIndex(prefabItemArray.arraySize - 1); + var prefabItemName = prefabItem.FindPropertyRelative("coreOptions.sublayerName"); + + prefabItemName.stringValue = "New Location"; + + // Set defaults here because SerializedProperty copies the previous element. + prefabItem.FindPropertyRelative("coreOptions.isActive").boolValue = true; + prefabItem.FindPropertyRelative("coreOptions.snapToTerrain").boolValue = true; + var categories = prefabItem.FindPropertyRelative("categories"); + categories.intValue = (int)(LocationPrefabCategories.AnyCategory);//To select any category option + + var density = prefabItem.FindPropertyRelative("density"); + density.intValue = 15;//To select all locations option + + selectedLayers = new int[1] { prefabItemArray.arraySize - 1 }; + layerTreeView.SetSelection(selectedLayers); + + + } + if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright")) + { + foreach (var index in selectedLayers.OrderByDescending(i => i)) + { + prefabItemArray.DeleteArrayElementAtIndex(index); + } + selectedLayers = new int[0]; + layerTreeView.SetSelection(selectedLayers); + } + + GUILayout.EndHorizontal(); + + if (selectedLayers.Count == 1 && prefabItemArray.arraySize != 0) + { + //ensure that selectedLayers[0] isn't out of bounds + if (selectedLayers[0] > prefabItemArray.arraySize - 1) + { + selectedLayers[0] = prefabItemArray.arraySize - 1; + } + SelectionIndex = selectedLayers[0]; + + var layerProperty = prefabItemArray.GetArrayElementAtIndex(SelectionIndex); + + layerProperty.isExpanded = true; + var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); + bool isLayerActive = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue; + if (!isLayerActive) + { + GUI.enabled = false; + } + + DrawLayerLocationPrefabProperties(layerProperty); + if (!isLayerActive) + { + GUI.enabled = true; + } + } + else + { + GUILayout.Space(15); + GUILayout.Label("Select a visualizer to see properties"); + } + } + + + void DrawLayerLocationPrefabProperties(SerializedProperty layerProperty) + { + EditorGUILayout.PropertyField(layerProperty); + } + } +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapExtentOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapExtentOptionsDrawer.cs index bfbfbe498..af8ad507e 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapExtentOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapExtentOptionsDrawer.cs @@ -9,16 +9,11 @@ public class MapExtentOptionsDrawer : PropertyDrawer { static string extTypePropertyName = "extentType"; - static float lineHeight = EditorGUIUtility.singleLineHeight; + static float _lineHeight = EditorGUIUtility.singleLineHeight; GUIContent[] extentTypeContent; bool isGUIContentSet = false; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - - position.height = lineHeight; - - var kindProperty = property.FindPropertyRelative(extTypePropertyName); var displayNames = kindProperty.enumDisplayNames; int count = kindProperty.enumDisplayNames.Length; @@ -36,62 +31,36 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten isGUIContentSet = true; } // Draw label. - var kindPosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = "Options to determine the geographic extent of the world for which the map tiles will be requested.", }); - - kindProperty.enumValueIndex = EditorGUI.Popup(kindPosition, kindProperty.enumValueIndex, extentTypeContent); + var extentTypeLabel = new GUIContent + { + text = label.text, + tooltip = "Options to determine the geographic extent of the world for which the map tiles will be requested.", + }; + kindProperty.enumValueIndex = EditorGUILayout.Popup(extentTypeLabel, kindProperty.enumValueIndex, extentTypeContent, GUILayout.Height(_lineHeight)); var kind = (MapExtentType)kindProperty.enumValueIndex; EditorGUI.indentLevel++; - var rect = new Rect(position.x, position.y + lineHeight, position.width, lineHeight); - + //var rect = new Rect(position.x, position.y + lineHeight, position.width, lineHeight); + GUILayout.Space(-_lineHeight); switch (kind) { case MapExtentType.CameraBounds: - EditorGUI.PropertyField(rect, property.FindPropertyRelative("cameraBoundsOptions"), new GUIContent { text = "CameraOptions-" }); + EditorGUILayout.PropertyField(property.FindPropertyRelative("cameraBoundsOptions"), new GUIContent { text = "CameraOptions-" }); break; case MapExtentType.RangeAroundCenter: - EditorGUI.PropertyField(rect, property.FindPropertyRelative("rangeAroundCenterOptions"), new GUIContent { text = "RangeAroundCenter" }); + EditorGUILayout.PropertyField(property.FindPropertyRelative("rangeAroundCenterOptions"), new GUIContent { text = "RangeAroundCenter" }); break; case MapExtentType.RangeAroundTransform: - EditorGUI.PropertyField(rect, property.FindPropertyRelative("rangeAroundTransformOptions"), new GUIContent { text = "RangeAroundTransform" }); + EditorGUILayout.PropertyField(property.FindPropertyRelative("rangeAroundTransformOptions"), new GUIContent { text = "RangeAroundTransform" }); break; default: break; } EditorGUI.indentLevel--; - - EditorGUI.EndProperty(); - - - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - var kindProperty = property.FindPropertyRelative(extTypePropertyName); - - var kind = (MapExtentType)kindProperty.enumValueIndex; - - int rows = 1; - - switch (kind) - { - case MapExtentType.CameraBounds: - rows += 2; - break; - case MapExtentType.RangeAroundCenter: - rows += 4; - break; - case MapExtentType.RangeAroundTransform: - rows += 3; - break; - default: - break; - } - return (float)rows * EditorGUIUtility.singleLineHeight; } - } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs index f22f367cf..d18424752 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs @@ -7,26 +7,15 @@ [CustomPropertyDrawer(typeof(MapLocationOptions))] public class MapLocationOptionsDrawer : PropertyDrawer { - static float lineHeight = EditorGUIUtility.singleLineHeight; + static float _lineHeight = EditorGUIUtility.singleLineHeight; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - //EditorGUI.indentLevel++; - foreach (var item in property) - { - var subproperty = item as SerializedProperty; - EditorGUI.PropertyField(position, subproperty, true); - position.height = lineHeight; - position.y += lineHeight; - } - //EditorGUI.indentLevel--; - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - // Reserve space for the total visible properties. - return (2.0f * lineHeight); + EditorGUI.indentLevel++; + GUILayout.Space(-2f * _lineHeight); + EditorGUILayout.PropertyField(property.FindPropertyRelative("latitudeLongitude")); + EditorGUILayout.PropertyField(property.FindPropertyRelative("zoom"), GUILayout.Height(_lineHeight)); + EditorGUI.indentLevel--; } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapPlacementOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapPlacementOptionsDrawer.cs index 94e46b57b..70c2c9ffd 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapPlacementOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapPlacementOptionsDrawer.cs @@ -13,7 +13,6 @@ public class MapPlacementOptionsDrawer : PropertyDrawer bool isGUIContentSet = false; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); var placementType = property.FindPropertyRelative("placementType"); var snapMapToTerrain = property.FindPropertyRelative("snapMapToZero"); @@ -33,20 +32,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten isGUIContentSet = true; } - // Draw label. - var placementTypePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = "Placement of Map root.", }); - - placementType.enumValueIndex = EditorGUI.Popup(placementTypePosition, placementType.enumValueIndex, placementTypeContent); - - //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), placementType, new GUIContent { text = placementType.displayName, tooltip = EnumExtensions.Description((MapPlacementType)placementType.enumValueIndex) }); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), snapMapToTerrain, new GUIContent { text = snapMapToTerrain.displayName, tooltip = "If checked, map's root will be snapped to zero. " }); - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - // Reserve space for the total visible properties. - return 2.0f * lineHeight; + placementType.enumValueIndex = EditorGUILayout.Popup(new GUIContent { text = label.text, tooltip = "Placement of Map root.", }, placementType.enumValueIndex, placementTypeContent); + EditorGUILayout.PropertyField(snapMapToTerrain, new GUIContent { text = snapMapToTerrain.displayName, tooltip = "If checked, map's root will be snapped to zero. " }); } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapScalingOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapScalingOptionsDrawer.cs index 2a219fa9b..8639b3968 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapScalingOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapScalingOptionsDrawer.cs @@ -14,7 +14,6 @@ public class MapScalingOptionsDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); var scalingType = property.FindPropertyRelative("scalingType"); var displayNames = scalingType.enumDisplayNames; int count = scalingType.enumDisplayNames.Length; @@ -33,28 +32,14 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } // Draw label. - var scalingTypePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = "Scale of map in game units.", }); + var scalingTypeLabel = new GUIContent { text = label.text, tooltip = "Scale of map in game units.", }; - scalingType.enumValueIndex = EditorGUI.Popup(scalingTypePosition, scalingType.enumValueIndex, scalingTypeContent); + scalingType.enumValueIndex = EditorGUILayout.Popup(scalingTypeLabel, scalingType.enumValueIndex, scalingTypeContent); if ((MapScalingType)scalingType.enumValueIndex == MapScalingType.Custom) { position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("unityTileSize")); - } - EditorGUI.EndProperty(); - } - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - // Reserve space for the total visible properties. - var scalingType = property.FindPropertyRelative("scalingType"); - if ((MapScalingType)scalingType.enumValueIndex == MapScalingType.Custom) - { - return 2.0f * lineHeight; - } - else - { - return 1.0f * lineHeight; + EditorGUILayout.PropertyField(property.FindPropertyRelative("unityTileSize")); } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs index c9bce3488..03b49658c 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs @@ -5,13 +5,14 @@ namespace Mapbox.Editor using UnityEditor; using System; using System.Collections.Generic; + using Mapbox.VectorTile.ExtensionMethods; [CustomPropertyDrawer(typeof(PrefabItemOptions))] public class PrefabItemOptionsDrawer : PropertyDrawer { static float _lineHeight = EditorGUIUtility.singleLineHeight; - private int shiftLeftPixels = -16; + const string searchButtonContent = "Search"; private GUIContent prefabLocationsTitle = new GUIContent { text = "Prefab Locations", @@ -31,7 +32,7 @@ public class PrefabItemOptionsDrawer : PropertyDrawer tooltip = "Spawn at locations in the categories selected" }; - private GUIContent densitySlider = new GUIContent + private GUIContent densitySlider = new GUIContent { text = "Density", tooltip = "The number of prefabs to spawn per-tile; try a lower number if the map is cluttered" @@ -43,40 +44,59 @@ public class PrefabItemOptionsDrawer : PropertyDrawer tooltip = "Spawn at locations containing this name string" }; + GUIContent[] findByPropContent; + bool isGUIContentSet = false; + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - - position.y += 1.2f*_lineHeight; - + GUILayout.Space(-_lineHeight); var prefabItemCoreOptions = property.FindPropertyRelative("coreOptions"); GUILayout.Label(prefabItemCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties"); - GUILayout.Space(2.5f*EditorGUIUtility.singleLineHeight); + //GUILayout.Space(2.5f * EditorGUIUtility.singleLineHeight); + //Prefab Game Object - position.y += _lineHeight; + GUILayout.Space(-_lineHeight); + EditorGUI.indentLevel++; var spawnPrefabOptions = property.FindPropertyRelative("spawnPrefabOptions"); - EditorGUI.PropertyField(new Rect(position.x, position.y + 2,position.width,2*_lineHeight),spawnPrefabOptions); + EditorGUILayout.PropertyField(spawnPrefabOptions); GUILayout.Space(1); + EditorGUI.indentLevel--; //Prefab Locations title GUILayout.Label(prefabLocationsTitle); //FindBy drop down - EditorGUI.indentLevel--; EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel(findByDropDown); + var findByProp = property.FindPropertyRelative("findByType"); - GUILayout.Space(shiftLeftPixels); - findByProp.enumValueIndex = EditorGUILayout.Popup(findByProp.enumValueIndex, findByProp.enumDisplayNames); + + var displayNames = findByProp.enumDisplayNames; + int count = findByProp.enumDisplayNames.Length; + if (!isGUIContentSet) + { + findByPropContent = new GUIContent[count]; + for (int extIdx = 0; extIdx < count; extIdx++) + { + findByPropContent[extIdx] = new GUIContent + { + text = displayNames[extIdx], + tooltip = ((ImagerySourceType)extIdx).Description(), + }; + } + isGUIContentSet = true; + } + EditorGUI.indentLevel++; + findByProp.enumValueIndex = EditorGUILayout.Popup(findByDropDown, findByProp.enumValueIndex, findByPropContent); + EditorGUILayout.EndHorizontal(); - switch((LocationPrefabFindBy)findByProp.enumValueIndex) + switch ((LocationPrefabFindBy)findByProp.enumValueIndex) { case (LocationPrefabFindBy.MapboxCategory): ShowCategoryOptions(property); break; - case(LocationPrefabFindBy.AddressOrLatLon): + case (LocationPrefabFindBy.AddressOrLatLon): ShowAddressOrLatLonUI(property); break; case (LocationPrefabFindBy.POIName): @@ -85,28 +105,20 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten default: break; } - EditorGUI.indentLevel++; - - EditorGUI.EndProperty(); + EditorGUI.indentLevel--; } private void ShowCategoryOptions(SerializedProperty property) { //Category drop down - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel(categoriesDropDown); - var categoryProp = property.FindPropertyRelative("categories"); - GUILayout.Space(shiftLeftPixels); - categoryProp.intValue = (int)(LocationPrefabCategories)(EditorGUILayout.EnumFlagsField((LocationPrefabCategories)categoryProp.intValue)); - EditorGUILayout.EndHorizontal(); - + categoryProp.intValue = (int)(LocationPrefabCategories)(EditorGUILayout.EnumFlagsField(categoriesDropDown, (LocationPrefabCategories)categoryProp.intValue)); ShowDensitySlider(property); } private void ShowAddressOrLatLonUI(SerializedProperty property) { - EditorGUILayout.BeginVertical(); + //EditorGUILayout.BeginVertical(); var coordinateProperties = property.FindPropertyRelative("coordinates"); for (int i = 0; i < coordinateProperties.arraySize; i++) @@ -115,11 +127,20 @@ private void ShowAddressOrLatLonUI(SerializedProperty property) //get the element to draw var coordinate = coordinateProperties.GetArrayElementAtIndex(i); - //use the tagged property drawer for the coordinate layout - EditorGUILayout.PropertyField(coordinate); + //label for each location. + var coordinateLabel = String.Format("Location {0}", i); + + // draw coordinate string. + coordinate.stringValue = EditorGUILayout.TextField(coordinateLabel, coordinate.stringValue); + + // draw search button. + if (GUILayout.Button(new GUIContent(searchButtonContent), (GUIStyle)"minibuttonleft", GUILayout.MaxWidth(100))) + { + GeocodeAttributeSearchWindow.Open(coordinate); + } //include a remove button in the row - if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.MaxWidth(30))) { coordinateProperties.DeleteArrayElementAtIndex(i); } @@ -127,31 +148,24 @@ private void ShowAddressOrLatLonUI(SerializedProperty property) } EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel(" "); - GUILayout.Space(-5); - if(GUILayout.Button( "Add Location")) + GUILayout.Space(EditorGUIUtility.labelWidth - 3); + + if (GUILayout.Button(new GUIContent("Add Location"), (GUIStyle)"minibutton")) { - coordinateProperties.arraySize++; var newElement = coordinateProperties.GetArrayElementAtIndex(coordinateProperties.arraySize - 1); newElement.stringValue = ""; } EditorGUILayout.EndHorizontal(); - EditorGUILayout.EndVertical(); } private void ShowPOINames(SerializedProperty property) { //Name field - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel(nameField); - var categoryProp = property.FindPropertyRelative("nameString"); - GUILayout.Space(shiftLeftPixels); - categoryProp.stringValue = EditorGUILayout.TextField(categoryProp.stringValue); - EditorGUILayout.EndHorizontal(); + categoryProp.stringValue = EditorGUILayout.TextField(nameField, categoryProp.stringValue); ShowDensitySlider(property); } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeAroundTransformTileProviderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeAroundTransformTileProviderOptionsDrawer.cs index e2344767b..76ce40176 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeAroundTransformTileProviderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeAroundTransformTileProviderOptionsDrawer.cs @@ -11,17 +11,13 @@ public class RangeAroundTransformTileProviderOptionsDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - //EditorGUI.indentLevel++; foreach (var item in property) { var subproperty = item as SerializedProperty; - EditorGUI.PropertyField(position, subproperty, true); + EditorGUILayout.PropertyField(subproperty, true); position.height = lineHeight; position.y += lineHeight; } - //EditorGUI.indentLevel--; - EditorGUI.EndProperty(); } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeTileProviderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeTileProviderOptionsDrawer.cs index dd7d7e5c0..f29868ad4 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeTileProviderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/RangeTileProviderOptionsDrawer.cs @@ -10,17 +10,13 @@ public class RangeTileProviderOptionsDrawer : PropertyDrawer static float lineHeight = EditorGUIUtility.singleLineHeight; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - //EditorGUI.indentLevel++; foreach (var item in property) { var subproperty = item as SerializedProperty; - EditorGUI.PropertyField(position, subproperty, true); + EditorGUILayout.PropertyField(subproperty, true); position.height = lineHeight; position.y += lineHeight; } - //EditorGUI.indentLevel--; - EditorGUI.EndProperty(); } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs index ccb20cc36..db309a088 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs @@ -1,41 +1,37 @@ -namespace Mapbox.Unity.Map -{ - using System.Collections; - using System.Collections.Generic; - using UnityEngine; - using Mapbox.Unity.MeshGeneration.Modifiers; - using UnityEditor; - - [CustomPropertyDrawer(typeof(SpawnPrefabOptions))] - public class SpawnPrefabOptionsDrawer : PropertyDrawer - { - static float lineHeight = EditorGUIUtility.singleLineHeight; - - private GUIContent prefabContent = new GUIContent - { - text = "Prefab", - tooltip = "The prefab to be spawned" - }; - - private GUIContent scalePrefabContent = new GUIContent - { - text = "Scale down with world", - tooltip = "The prefab will scale with the map object" - }; - - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - EditorGUI.BeginProperty(position, label, property); - position.height = 2.5f * lineHeight; - EditorGUI.PropertyField(new Rect(position.x,position.y,position.width,lineHeight),property.FindPropertyRelative("prefab"), prefabContent); - position.y += lineHeight; - EditorGUI.PropertyField(new Rect(position.x, position.y, position.width,lineHeight),property.FindPropertyRelative("scaleDownWithWorld"), scalePrefabContent); - EditorGUI.EndProperty(); - } - - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - return 0; - } - } -} +namespace Mapbox.Unity.Map +{ + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + using Mapbox.Unity.MeshGeneration.Modifiers; + using UnityEditor; + + [CustomPropertyDrawer(typeof(SpawnPrefabOptions))] + public class SpawnPrefabOptionsDrawer : PropertyDrawer + { + static float lineHeight = EditorGUIUtility.singleLineHeight; + + private GUIContent prefabContent = new GUIContent + { + text = "Prefab", + tooltip = "The prefab to be spawned" + }; + + private GUIContent scalePrefabContent = new GUIContent + { + text = "Scale down with world", + tooltip = "The prefab will scale with the map object" + }; + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField(property.FindPropertyRelative("prefab"), prefabContent); + EditorGUILayout.PropertyField(property.FindPropertyRelative("scaleDownWithWorld"), scalePrefabContent); + } + + //public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + //{ + // return 0; + //} + } +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/StyleOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/StyleOptionsDrawer.cs index 0e84f68a9..04cd7e80b 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/StyleOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/StyleOptionsDrawer.cs @@ -11,13 +11,8 @@ public class StyleOptionsDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - - position.height = lineHeight; - - EditorGUI.PropertyField(position, property.FindPropertyRelative("Id"), label); - - EditorGUI.EndProperty(); + GUILayout.Space(-lineHeight); + EditorGUILayout.PropertyField(property.FindPropertyRelative("Id"), label); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs index 588fb0ef5..3021b66be 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -39,12 +39,12 @@ int SelectionIndex public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - position.height = _lineHeight; + //EditorGUI.BeginProperty(position, label, property); + //position.height = _lineHeight; GUILayout.Space(-_lineHeight); var sourceTypeProperty = property.FindPropertyRelative("_sourceType"); - var sourceTypeValue = (VectorSourceType) sourceTypeProperty.enumValueIndex; + var sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; if (sourceTypeValue != VectorSourceType.None) { @@ -58,6 +58,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var layersRect = GUILayoutUtility.GetRect(0, 500, Mathf.Max(subLayerArray.arraySize + 1, 1) * _lineHeight, (subLayerArray.arraySize + 1) * _lineHeight); + //Debug.Log("Indent" + EditorGUIUtility.standardVerticalSpacing); + //layersRect.x += (EditorGUIUtility.singleLineHeight * (EditorGUI.indentLevel + 1)); layerTreeView.Layers = subLayerArray; layerTreeView.Reload(); layerTreeView.OnGUI(layersRect); @@ -79,7 +81,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } else { - selectedLayers = new int[1] {SelectionIndex}; + selectedLayers = new int[1] { SelectionIndex }; if (SelectionIndex > 0 && (SelectionIndex <= subLayerArray.arraySize - 1)) { layerTreeView.SetSelection(selectedLayers); @@ -90,7 +92,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten GUILayout.BeginHorizontal(); - if (GUILayout.Button(new GUIContent("Add Visualizer"), (GUIStyle) "minibuttonleft")) + if (GUILayout.Button(new GUIContent("Add Visualizer"), (GUIStyle)"minibuttonleft")) { subLayerArray.arraySize++; //subLayerArray.InsertArrayElementAtIndex(subLayerArray.arraySize); @@ -104,43 +106,43 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var subLayerCoreOptions = subLayer.FindPropertyRelative("coreOptions"); subLayerCoreOptions.FindPropertyRelative("isActive").boolValue = true; subLayerCoreOptions.FindPropertyRelative("layerName").stringValue = "building"; - subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex = (int) VectorPrimitiveType.Polygon; + subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex = (int)VectorPrimitiveType.Polygon; subLayerCoreOptions.FindPropertyRelative("snapToTerrain").boolValue = true; subLayerCoreOptions.FindPropertyRelative("groupFeatures").boolValue = false; subLayerCoreOptions.FindPropertyRelative("lineWidth").floatValue = 1.0f; var subLayerExtrusionOptions = subLayer.FindPropertyRelative("extrusionOptions"); - subLayerExtrusionOptions.FindPropertyRelative("extrusionType").enumValueIndex = (int) ExtrusionType.None; + subLayerExtrusionOptions.FindPropertyRelative("extrusionType").enumValueIndex = (int)ExtrusionType.None; subLayerExtrusionOptions.FindPropertyRelative("extrusionGeometryType").enumValueIndex = - (int) ExtrusionGeometryType.RoofAndSide; + (int)ExtrusionGeometryType.RoofAndSide; subLayerExtrusionOptions.FindPropertyRelative("propertyName").stringValue = "height"; subLayerExtrusionOptions.FindPropertyRelative("extrusionScaleFactor").floatValue = 1f; var subLayerFilterOptions = subLayer.FindPropertyRelative("filterOptions"); subLayerFilterOptions.FindPropertyRelative("filters").ClearArray(); subLayerFilterOptions.FindPropertyRelative("combinerType").enumValueIndex = - (int) LayerFilterCombinerOperationType.Any; + (int)LayerFilterCombinerOperationType.Any; var subLayerMaterialOptions = subLayer.FindPropertyRelative("materialOptions"); subLayerMaterialOptions.FindPropertyRelative("materials").ClearArray(); subLayerMaterialOptions.FindPropertyRelative("materials").arraySize = 2; subLayerMaterialOptions.FindPropertyRelative("atlasInfo").objectReferenceValue = null; subLayerMaterialOptions.FindPropertyRelative("colorPalette").objectReferenceValue = null; - subLayerMaterialOptions.FindPropertyRelative("texturingType").enumValueIndex = (int) UvMapType.Tiled; + subLayerMaterialOptions.FindPropertyRelative("texturingType").enumValueIndex = (int)UvMapType.Tiled; subLayer.FindPropertyRelative("buildingsWithUniqueIds").boolValue = false; - subLayer.FindPropertyRelative("moveFeaturePositionTo").enumValueIndex = (int) PositionTargetType.TileCenter; + subLayer.FindPropertyRelative("moveFeaturePositionTo").enumValueIndex = (int)PositionTargetType.TileCenter; subLayer.FindPropertyRelative("MeshModifiers").ClearArray(); subLayer.FindPropertyRelative("GoModifiers").ClearArray(); var subLayerColliderOptions = subLayer.FindPropertyRelative("colliderOptions"); - subLayerColliderOptions.FindPropertyRelative("colliderType").enumValueIndex = (int) ColliderType.None; + subLayerColliderOptions.FindPropertyRelative("colliderType").enumValueIndex = (int)ColliderType.None; - selectedLayers = new int[1] {subLayerArray.arraySize - 1}; + selectedLayers = new int[1] { subLayerArray.arraySize - 1 }; layerTreeView.SetSelection(selectedLayers); } - if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle) "minibuttonright")) + if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright")) { foreach (var index in selectedLayers.OrderByDescending(i => i)) { @@ -155,7 +157,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten GUILayout.Space(EditorGUIUtility.singleLineHeight); - if (selectedLayers.Count == 1 && subLayerArray.arraySize!=0) + if (selectedLayers.Count == 1 && subLayerArray.arraySize != 0) { //ensure that selectedLayers[0] isn't out of bounds if (selectedLayers[0] > subLayerArray.arraySize - 1) @@ -187,32 +189,33 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } } - EditorGUI.EndProperty(); + //EditorGUI.EndProperty(); } void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty) { - EditorGUI.indentLevel--; var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); - EditorGUI.indentLevel++; GUILayout.Label(subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties"); GUILayout.BeginVertical(); - + EditorGUI.indentLevel++; VectorPrimitiveType primitiveTypeProp = - (VectorPrimitiveType) subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex; + (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex; + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(subLayerCoreOptions); if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom) { + GUILayout.Space(-_lineHeight); EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("colliderOptions")); - + GUILayout.Space(-_lineHeight); + EditorGUI.indentLevel--; EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("extrusionOptions")); - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions")); + EditorGUI.indentLevel++; } - //EditorGUI.indentLevel--; + EditorGUI.indentLevel--; ShowOthers = EditorGUILayout.Foldout(ShowOthers, "Advanced"); EditorGUI.indentLevel++; if (ShowOthers) @@ -289,12 +292,12 @@ void DrawModifiers(SerializedProperty property, GUIContent label) EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false) as ScriptableObject; EditorGUILayout.EndVertical(); - if (GUILayout.Button(new GUIContent("+"), (GUIStyle) "minibuttonleft", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent("+"), (GUIStyle)"minibuttonleft", GUILayout.Width(30))) { ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac, ind); } - if (GUILayout.Button(new GUIContent("-"), (GUIStyle) "minibuttonright", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30))) { meshfac.DeleteArrayElementAtIndex(ind); } @@ -306,13 +309,13 @@ void DrawModifiers(SerializedProperty property, GUIContent label) EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(EditorGUI.indentLevel * 12); - if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle) "minibuttonleft")) + if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft")) { meshfac.arraySize++; meshfac.GetArrayElementAtIndex(meshfac.arraySize - 1).objectReferenceValue = null; } - if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle) "minibuttonright")) + if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright")) { ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac); } @@ -337,12 +340,12 @@ void DrawModifiers(SerializedProperty property, GUIContent label) false) as ScriptableObject; EditorGUILayout.EndVertical(); - if (GUILayout.Button(new GUIContent("+"), (GUIStyle) "minibuttonleft", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent("+"), (GUIStyle)"minibuttonleft", GUILayout.Width(30))) { ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac, ind); } - if (GUILayout.Button(new GUIContent("-"), (GUIStyle) "minibuttonright", GUILayout.Width(30))) + if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30))) { gofac.DeleteArrayElementAtIndex(ind); } @@ -354,13 +357,13 @@ void DrawModifiers(SerializedProperty property, GUIContent label) EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(EditorGUI.indentLevel * 12); - if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle) "minibuttonleft")) + if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft")) { gofac.arraySize++; gofac.GetArrayElementAtIndex(gofac.arraySize - 1).objectReferenceValue = null; } - if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle) "minibuttonright")) + if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright")) { ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac); } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs index e20612878..16ebe7188 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs @@ -33,7 +33,7 @@ protected override TreeViewItem BuildRoot() for (int i = 0; i < Layers.arraySize; i++) { var name = Layers.GetArrayElementAtIndex(i).FindPropertyRelative("coreOptions.sublayerName").stringValue; - items.Add(new TreeViewItem { id = index, depth = 0, displayName = name }); + items.Add(new TreeViewItem { id = index, depth = 1, displayName = name }); index++; } } @@ -61,16 +61,16 @@ protected override void RenameEnded(RenameEndedArgs args) layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = string.IsNullOrEmpty(args.newName.Trim()) ? args.originalName : args.newName; } - protected override void RowGUI (RowGUIArgs args) + protected override void RowGUI(RowGUIArgs args) { - EditorGUI.indentLevel--; + //EditorGUI.indentLevel--; Rect toggleRect = args.rowRect; toggleRect.width = kToggleWidth; var item = Layers.GetArrayElementAtIndex(args.item.id); item.FindPropertyRelative("coreOptions.isActive").boolValue = EditorGUI.Toggle(toggleRect, item.FindPropertyRelative("coreOptions.isActive").boolValue); args.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue; base.RowGUI(args); - EditorGUI.indentLevel++; + //EditorGUI.indentLevel++; } } }