diff --git a/sdkproject/Assets/Mapbox/Examples/_sharedModules/FlatTerrainFactory.asset b/sdkproject/Assets/Mapbox/Examples/_sharedModules/FlatTerrainFactory.asset deleted file mode 100644 index 92496026e..000000000 --- a/sdkproject/Assets/Mapbox/Examples/_sharedModules/FlatTerrainFactory.asset +++ /dev/null @@ -1,17 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &11400000 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0a6523094c07d4ee683da5d826fce510, type: 3} - m_Name: FlatTerrainFactory - m_EditorClassIdentifier: - _baseMaterial: {fileID: 2100000, guid: b9f23e9bce724fa4daac57ecded470b8, type: 2} - _addCollider: 0 - _addToLayer: 0 - _layerId: 0 diff --git a/sdkproject/Assets/Mapbox/Examples/_sharedModules/FlatTerrainFactory.asset.meta b/sdkproject/Assets/Mapbox/Examples/_sharedModules/FlatTerrainFactory.asset.meta deleted file mode 100644 index 0a9cf819f..000000000 --- a/sdkproject/Assets/Mapbox/Examples/_sharedModules/FlatTerrainFactory.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6b6c6a798b018ed449bccff86fbf6fd8 -timeCreated: 1502761717 -licenseType: Pro -NativeFormatImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/_sharedModules/GlobeTerrainFactory.asset b/sdkproject/Assets/Mapbox/Examples/_sharedModules/GlobeTerrainFactory.asset deleted file mode 100644 index 1ca9f3760..000000000 --- a/sdkproject/Assets/Mapbox/Examples/_sharedModules/GlobeTerrainFactory.asset +++ /dev/null @@ -1,38 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &11400000 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 859bc316b9b734bffaf7288cb86ffc0c, type: 3} - m_Name: GlobeTerrainFactory - m_EditorClassIdentifier: - _elevationOptions: - sourceType: 0 - sourceOptions: - isActive: 1 - layerSource: - Name: - Id: mapbox.terrain-rgb - Modified: - UserName: - elevationLayerType: 3 - requiredOptions: - baseMaterial: {fileID: 2100000, guid: b9f23e9bce724fa4daac57ecded470b8, type: 2} - addCollider: 0 - exaggerationFactor: 1 - modificationOptions: - sampleCount: 10 - useRelativeHeight: 0 - earthRadius: 1000 - unityLayerOptions: - addToLayer: 0 - layerId: 0 - sideWallOptions: - isActive: 0 - wallHeight: 10 - wallMaterial: {fileID: 0} diff --git a/sdkproject/Assets/Mapbox/Examples/_sharedModules/GlobeTerrainFactory.asset.meta b/sdkproject/Assets/Mapbox/Examples/_sharedModules/GlobeTerrainFactory.asset.meta deleted file mode 100644 index d956ead3e..000000000 --- a/sdkproject/Assets/Mapbox/Examples/_sharedModules/GlobeTerrainFactory.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6dee93d9a198a4699800e20d1e1ea6b6 -timeCreated: 1500049552 -licenseType: Pro -NativeFormatImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/_sharedModules/LowPolyTerrainFactory.asset b/sdkproject/Assets/Mapbox/Examples/_sharedModules/LowPolyTerrainFactory.asset deleted file mode 100644 index 156f18885..000000000 --- a/sdkproject/Assets/Mapbox/Examples/_sharedModules/LowPolyTerrainFactory.asset +++ /dev/null @@ -1,38 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &11400000 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 9ffef98732ebca048a22c90f6809321c, type: 3} - m_Name: LowPolyTerrainFactory - m_EditorClassIdentifier: - _elevationOptions: - sourceType: 0 - sourceOptions: - isActive: 1 - layerSource: - Name: - Id: mapbox.terrain-rgb - Modified: - UserName: - elevationLayerType: 2 - requiredOptions: - baseMaterial: {fileID: 2100000, guid: b9f23e9bce724fa4daac57ecded470b8, type: 2} - addCollider: 0 - exaggerationFactor: 1 - modificationOptions: - sampleCount: 10 - useRelativeHeight: 0 - earthRadius: 1000 - unityLayerOptions: - addToLayer: 0 - layerId: 0 - sideWallOptions: - isActive: 0 - wallHeight: 10 - wallMaterial: {fileID: 0} diff --git a/sdkproject/Assets/Mapbox/Examples/_sharedModules/LowPolyTerrainFactory.asset.meta b/sdkproject/Assets/Mapbox/Examples/_sharedModules/LowPolyTerrainFactory.asset.meta deleted file mode 100644 index 397de918a..000000000 --- a/sdkproject/Assets/Mapbox/Examples/_sharedModules/LowPolyTerrainFactory.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 516d89dfeaaf9c743935a4f89e93220c -timeCreated: 1501697876 -licenseType: Pro -NativeFormatImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/FeatureSubLayerTreeView.cs b/sdkproject/Assets/Mapbox/Unity/Editor/FeatureSubLayerTreeView.cs new file mode 100644 index 000000000..fdd9777b2 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Unity/Editor/FeatureSubLayerTreeView.cs @@ -0,0 +1,151 @@ +namespace Mapbox.Editor +{ + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + using UnityEditor.IMGUI.Controls; + using UnityEditor; + using Mapbox.Unity.Map; + + public class FeatureSubLayerTreeView : TreeView + { + public SerializedProperty Layers; + private float kToggleWidth = 18f; + public int uniqueId = 3000; + public FeatureSubLayerTreeView(TreeViewState state) + : base(state) + { + //uniqueId = treeViewControlID; + showAlternatingRowBackgrounds = true; + showBorder = true; + Reload(); + + } + + protected override TreeViewItem BuildRoot() + { + // The root item is required to have a depth of -1, and the rest of the items increment from that. + var root = new TreeViewItem { id = -1, depth = -1, displayName = "Root" }; + + var items = new List(); + var index = 0; + + if (Layers != null) + { + for (int i = 0; i < Layers.arraySize; i++) + { + var name = Layers.GetArrayElementAtIndex(i).FindPropertyRelative("coreOptions.sublayerName").stringValue; + items.Add(new TreeViewItem { id = index + uniqueId, depth = 1, displayName = name }); + index++; + } + } + + // Utility method that initializes the TreeViewItem.children and .parent for all items. + SetupParentsAndChildrenFromDepths(root, items); + + // Return root of the tree + return root; + } + + protected override bool CanRename(TreeViewItem item) + { + return true; + } + + protected override void RenameEnded(RenameEndedArgs args) + { + if (Layers == null) + { + return; + } + + var layer = Layers.GetArrayElementAtIndex(args.itemID - uniqueId); + layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = string.IsNullOrEmpty(args.newName.Trim()) ? args.originalName : args.newName; + } + + protected override void RowGUI(RowGUIArgs args) + { + Rect toggleRect = args.rowRect; + toggleRect.width = kToggleWidth; + var item = Layers.GetArrayElementAtIndex(args.item.id - uniqueId); + item.FindPropertyRelative("coreOptions.isActive").boolValue = EditorGUI.Toggle(toggleRect, item.FindPropertyRelative("coreOptions.isActive").boolValue); + args.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue; + base.RowGUI(args); + } + } +} +namespace Mapbox.Editor +{ + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + using UnityEditor.IMGUI.Controls; + using UnityEditor; + using Mapbox.Unity.Map; + + public class PointsOfInterestSubLayerTreeView : TreeView + { + public SerializedProperty Layers; + private float kToggleWidth = 18f; + private const int uniqueId = 0;//100000; + + public PointsOfInterestSubLayerTreeView(TreeViewState state) + : base(state) + { + showAlternatingRowBackgrounds = true; + showBorder = true; + Reload(); + } + + protected override TreeViewItem BuildRoot() + { + // The root item is required to have a depth of -1, and the rest of the items increment from that. + var root = new TreeViewItem { id = -1, depth = -1, displayName = "Root" }; + + var items = new List(); + var index = 0; + + if (Layers != null) + { + for (int i = 0; i < Layers.arraySize; i++) + { + var name = Layers.GetArrayElementAtIndex(i).FindPropertyRelative("coreOptions.sublayerName").stringValue; + items.Add(new TreeViewItem { id = index + uniqueId, depth = 1, displayName = name }); + index++; + } + } + + // Utility method that initializes the TreeViewItem.children and .parent for all items. + SetupParentsAndChildrenFromDepths(root, items); + + // Return root of the tree + return root; + } + + protected override bool CanRename(TreeViewItem item) + { + return true; + } + + protected override void RenameEnded(RenameEndedArgs args) + { + if (Layers == null) + { + return; + } + + var layer = Layers.GetArrayElementAtIndex(args.itemID - uniqueId); + layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = string.IsNullOrEmpty(args.newName.Trim()) ? args.originalName : args.newName; + } + + protected override void RowGUI(RowGUIArgs args) + { + Rect toggleRect = args.rowRect; + toggleRect.width = kToggleWidth; + var item = Layers.GetArrayElementAtIndex(args.item.id - uniqueId); + item.FindPropertyRelative("coreOptions.isActive").boolValue = EditorGUI.Toggle(toggleRect, item.FindPropertyRelative("coreOptions.isActive").boolValue); + args.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue; + base.RowGUI(args); + } + } +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs index 51e7d07f2..8b91fe6e8 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/GeocodeAttributeDrawer.cs @@ -16,21 +16,17 @@ public class GeocodeAttributeDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - GUILayout.BeginHorizontal(); - if (string.IsNullOrEmpty(label.text)) - { + float buttonWidth = EditorGUIUtility.singleLineHeight * 4; - 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))) + 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); + + if (GUI.Button(buttonRect, searchButtonContent)) { 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 ad311dfd1..9f44e8d01 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs @@ -67,43 +67,11 @@ bool ShowMapLayers { get { - return EditorPrefs.GetBool("MapManagerEditor_showMapLayers"); + return EditorPrefs.GetBool(objectId + "MapManagerEditor_showMapLayers"); } set { - EditorPrefs.SetBool("MapManagerEditor_showMapLayers", value); - } - } - - /// - /// Gets or sets a value to show or hide Vector section . - /// - /// true if show vector; otherwise, false. - bool ShowLocationPrefabs - { - get - { - return EditorPrefs.GetBool("MapManagerEditor_showLocationPrefabs"); - } - set - { - EditorPrefs.SetBool("MapManagerEditor_showLocationPrefabs", value); - } - } - - /// - /// Gets or sets a value to show or hide Vector section . - /// - /// true if show vector; otherwise, false. - bool ShowFeatures - { - get - { - return EditorPrefs.GetBool(objectId + "MapManagerEditor_showVector"); - } - set - { - EditorPrefs.SetBool(objectId + "MapManagerEditor_showVector", value); + EditorPrefs.SetBool(objectId + "MapManagerEditor_showMapLayers", value); } } @@ -119,12 +87,6 @@ bool ShowPosition } } - 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", @@ -179,7 +141,7 @@ public override void OnInspectorGUI() { DrawMapLayerOptions(); } - GUILayout.EndVertical(); + EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); } @@ -234,7 +196,6 @@ void DrawMapOptions(SerializedObject mapObject) void DrawMapLayerOptions() { - //EditorGUI.indentLevel++; var vectorDataProperty = serializedObject.FindProperty("_vectorData"); var layerProperty = vectorDataProperty.FindPropertyRelative("_layerProperty"); var layerSourceProperty = layerProperty.FindPropertyRelative("sourceOptions"); @@ -310,123 +271,8 @@ void DrawMapLayerOptions() 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 - //placement = atLocationCenter, - //scaling = custom - //turn off vector layers. - var mapOptionsProp = unifiedMap.FindPropertyRelative("mapOptions"); - var vectorLayerProps = unifiedMap.FindPropertyRelative("vectorLayerProperties"); - var placementType = mapOptionsProp.FindPropertyRelative("placementOptions.placementType"); - var scalingType = mapOptionsProp.FindPropertyRelative("scalingOptions.scalingType"); - var unitType = mapOptionsProp.FindPropertyRelative("scalingOptions.unitType"); - var extentType = mapOptionsProp.FindPropertyRelative("extentOptions.extentType"); - var vectorSourceType = vectorLayerProps.FindPropertyRelative("sourceType"); - - placementType.enumValueIndex = (int)MapPlacementType.AtLocationCenter; - - scalingType.enumValueIndex = (int)MapScalingType.Custom; - unitType.enumValueIndex = (int)MapUnitType.meters; - - extentType.enumValueIndex = (int)MapExtentType.CameraBounds; - - vectorSourceType.enumValueIndex = (int)VectorSourceType.None; - - } - - void PresetWorldSimulator(SerializedProperty unifiedMap) - { - //Set - //placement = atLocationCenter, - //scaling = custom - //turn on vector layers. - var mapOptionsProp = unifiedMap.FindPropertyRelative("mapOptions"); - var vectorLayerProps = unifiedMap.FindPropertyRelative("vectorLayerProperties"); - var placementType = mapOptionsProp.FindPropertyRelative("placementOptions.placementType"); - var scalingType = mapOptionsProp.FindPropertyRelative("scalingOptions.scalingType"); - var unitType = mapOptionsProp.FindPropertyRelative("scalingOptions.unitType"); - var extentType = mapOptionsProp.FindPropertyRelative("extentOptions.extentType"); - var vectorSourceType = vectorLayerProps.FindPropertyRelative("sourceType"); - - placementType.enumValueIndex = (int)MapPlacementType.AtLocationCenter; - - scalingType.enumValueIndex = (int)MapScalingType.Custom; - unitType.enumValueIndex = (int)MapUnitType.meters; - - extentType.enumValueIndex = (int)MapExtentType.CameraBounds; - - vectorSourceType.enumValueIndex = (int)VectorSourceType.MapboxStreets; - } - - void PresetARTableTop(SerializedProperty unifiedMap) - { - //Set - //placement = atLocationCenter, - //scaling = custom - //turn on vector layers. - var mapOptionsProp = unifiedMap.FindPropertyRelative("mapOptions"); - var vectorLayerProps = unifiedMap.FindPropertyRelative("vectorLayerProperties"); - var placementType = mapOptionsProp.FindPropertyRelative("placementOptions.placementType"); - var scalingType = mapOptionsProp.FindPropertyRelative("scalingOptions.scalingType"); - var extentType = mapOptionsProp.FindPropertyRelative("extentOptions.extentType"); - var vectorSourceType = vectorLayerProps.FindPropertyRelative("sourceType"); - - placementType.enumValueIndex = (int)MapPlacementType.AtLocationCenter; - - scalingType.enumValueIndex = (int)MapScalingType.WorldScale; - - extentType.enumValueIndex = (int)MapExtentType.CameraBounds; - - vectorSourceType.enumValueIndex = (int)VectorSourceType.MapboxStreets; - - } - - void PresetARWorldScale(SerializedProperty unifiedMap) - { - //Set - //placement = atLocationCenter, - //scaling = custom - //turn on vector layers. - var mapOptionsProp = unifiedMap.FindPropertyRelative("mapOptions"); - var vectorLayerProps = unifiedMap.FindPropertyRelative("vectorLayerProperties"); - var placementType = mapOptionsProp.FindPropertyRelative("placementOptions.placementType"); - var scalingType = mapOptionsProp.FindPropertyRelative("scalingOptions.scalingType"); - var extentType = mapOptionsProp.FindPropertyRelative("extentOptions.extentType"); - var vectorSourceType = vectorLayerProps.FindPropertyRelative("sourceType"); - - placementType.enumValueIndex = (int)MapPlacementType.AtLocationCenter; - - scalingType.enumValueIndex = (int)MapScalingType.WorldScale; - - extentType.enumValueIndex = (int)MapExtentType.CameraBounds; - - vectorSourceType.enumValueIndex = (int)VectorSourceType.MapboxStreets; - + GUILayout.Space(-2.0f * _lineHeight); + ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty"); } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/ModifierStackEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/ModifierStackEditor.cs index 09df52811..fe674e964 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/ModifierStackEditor.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/ModifierStackEditor.cs @@ -14,7 +14,7 @@ public class ModifierStackEditor : UnityEditor.Editor private void OnEnable() { script = MonoScript.FromScriptableObject((ModifierStack)target); - _positionType = serializedObject.FindProperty("_moveFeaturePositionTo"); + _positionType = serializedObject.FindProperty("moveFeaturePositionTo"); } public override void OnInspectorGUI() diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs index 215a84363..ede4adea5 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ColliderOptionsDrawer.cs @@ -15,6 +15,7 @@ public class ColliderOptionsDrawer : PropertyDrawer GUIContent[] colliderTypeContent; public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + EditorGUI.BeginProperty(position, null, property); var colliderTypeLabel = new GUIContent { text = "Collider Type", @@ -39,7 +40,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten isGUIContentSet = true; } - colliderTypeProperty.enumValueIndex = EditorGUILayout.Popup(colliderTypeLabel, colliderTypeProperty.enumValueIndex, colliderTypeContent); + colliderTypeProperty.enumValueIndex = EditorGUI.Popup(position, colliderTypeLabel, colliderTypeProperty.enumValueIndex, colliderTypeContent); + EditorGUI.EndProperty(); + } + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + return lineHeight; } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs index 9e01902d8..b23584d1b 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/CoreVectorLayerPropertiesDrawer.cs @@ -35,8 +35,10 @@ int index public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + EditorGUI.BeginProperty(position, null, property); objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); + // Draw label. var primitiveType = property.FindPropertyRelative("geometryType"); @@ -80,8 +82,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten index = 0; } currentSource = newSource; - - DrawLayerName(property, position, layerDisplayNames); } else { @@ -89,6 +89,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten currentSource = newSource; } + DrawLayerName(property, position, layerDisplayNames); + EditorGUILayout.PropertyField(property.FindPropertyRelative("snapToTerrain")); EditorGUILayout.PropertyField(property.FindPropertyRelative("groupFeatures")); @@ -96,6 +98,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { EditorGUILayout.PropertyField(property.FindPropertyRelative("lineWidth")); } + EditorGUI.EndProperty(); } private static int count = 0; private void DrawLayerName(SerializedProperty property, Rect position, List layerDisplayNames) diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/FeaturesSubLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/FeaturesSubLayerPropertiesDrawer.cs new file mode 100644 index 000000000..07e837754 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/FeaturesSubLayerPropertiesDrawer.cs @@ -0,0 +1,534 @@ +namespace Mapbox.Editor +{ + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + using UnityEditor; + using Mapbox.Unity.Map; + using UnityEditor.IMGUI.Controls; + using Mapbox.Unity.MeshGeneration.Modifiers; + using Mapbox.VectorTile.ExtensionMethods; + using Mapbox.Unity.MeshGeneration.Filters; + using Mapbox.Platform.TilesetTileJSON; + + public class FeaturesSubLayerPropertiesDrawer + { + static float _lineHeight = EditorGUIUtility.singleLineHeight; + GUIContent[] _sourceTypeContent; + bool _isGUIContentSet = false; + bool _isInitialized = false; + private TileJsonData tileJSONData; + private static TileJSONResponse tileJSONResponse; + /// + /// Gets or sets the layerID + /// + /// true then show general section; otherwise hide, false. + + string objectId = ""; + private string TilesetId + { + get + { + return EditorPrefs.GetString(objectId + "VectorSubLayerProperties_tilesetId"); + } + set + { + EditorPrefs.SetString(objectId + "VectorSubLayerProperties_tilesetId", value); + } + } + + bool ShowPosition + { + get + { + return EditorPrefs.GetBool(objectId + "VectorSubLayerProperties_showPosition"); + } + set + { + EditorPrefs.SetBool(objectId + "VectorSubLayerProperties_showPosition", value); + } + } + + bool ShowOthers + { + get + { + return EditorPrefs.GetBool(objectId + "VectorSubLayerProperties_showOthers"); + } + set + { + EditorPrefs.SetBool(objectId + "VectorSubLayerProperties_showOthers", value); + } + } + + int SelectionIndex + { + get + { + return EditorPrefs.GetInt(objectId + "VectorSubLayerProperties_selectionIndex"); + } + set + { + EditorPrefs.SetInt(objectId + "VectorSubLayerProperties_selectionIndex", value); + } + } + + string CustomSourceMapId + { + get + { + return EditorPrefs.GetString(objectId + "VectorSubLayerProperties_customSourceMapId"); + } + set + { + EditorPrefs.SetString(objectId + "VectorSubLayerProperties_customSourceMapId", value); + } + } + + FeatureSubLayerTreeView layerTreeView = new FeatureSubLayerTreeView(new TreeViewState()); + IList selectedLayers = new List(); + + private GUIContent _mapIdGui = new GUIContent + { + text = "Map Id", + tooltip = "Map Id corresponding to the tileset." + }; + + public void DrawUI(SerializedProperty property) + { + objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); + var serializedMapObject = property.serializedObject; + AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; + tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; + + 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; + } + + sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; + + 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; + if (_isInitialized) + { + LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); + } + else + { + _isInitialized = true; + } + if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded) + { + EditorGUILayout.HelpBox("Invalid Map Id / There might be a problem with the internet connection.", MessageType.Error); + } + GUI.enabled = true; + isActiveProperty.boolValue = true; + break; + case VectorSourceType.Custom: + layerSourceId.stringValue = CustomSourceMapId; + if (_isInitialized) + { + LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); + } + else + { + _isInitialized = true; + } + if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded) + { + 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: + isActiveProperty.boolValue = false; + break; + default: + isActiveProperty.boolValue = false; + break; + } + + if (sourceTypeValue != VectorSourceType.None) + { + EditorGUILayout.LabelField(new GUIContent + { + text = "Vector Layer Visualizers", + tooltip = "Visualizers for vector features contained in a layer. " + }); + + var subLayerArray = property.FindPropertyRelative("vectorSubLayers"); + + var layersRect = EditorGUILayout.GetControlRect(GUILayout.MinHeight(Mathf.Max(subLayerArray.arraySize + 1, 1) * _lineHeight), + GUILayout.MaxHeight((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. + //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] - layerTreeView.uniqueId > subLayerArray.arraySize - 1) + { + selectedLayers[0] = subLayerArray.arraySize - 1 + layerTreeView.uniqueId; + } + + SelectionIndex = selectedLayers[0]; + } + else + { + if (SelectionIndex > 0 && (SelectionIndex - layerTreeView.uniqueId <= subLayerArray.arraySize - 1)) + { + selectedLayers = new int[1] { SelectionIndex }; + layerTreeView.SetSelection(selectedLayers); + } + } + + GUILayout.Space(EditorGUIUtility.singleLineHeight); + + EditorGUILayout.BeginHorizontal(); + + if (GUILayout.Button(new GUIContent("Add Visualizer"), (GUIStyle)"minibuttonleft")) + { + subLayerArray.arraySize++; + + var subLayer = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1); + var subLayerName = subLayer.FindPropertyRelative("coreOptions.sublayerName"); + + subLayerName.stringValue = "Untitled"; + + // Set defaults here because SerializedProperty copies the previous element. + var subLayerCoreOptions = subLayer.FindPropertyRelative("coreOptions"); + subLayerCoreOptions.FindPropertyRelative("isActive").boolValue = true; + subLayerCoreOptions.FindPropertyRelative("layerName").stringValue = "building"; + 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("extrusionGeometryType").enumValueIndex = + (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; + + 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; + + subLayer.FindPropertyRelative("buildingsWithUniqueIds").boolValue = false; + 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; + + selectedLayers = new int[1] { subLayerArray.arraySize - 1 + layerTreeView.uniqueId }; + layerTreeView.SetSelection(selectedLayers); + } + + if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright")) + { + foreach (var index in selectedLayers.OrderByDescending(i => i)) + { + subLayerArray.DeleteArrayElementAtIndex(index - layerTreeView.uniqueId); + } + + selectedLayers = new int[0]; + layerTreeView.SetSelection(selectedLayers); + } + + EditorGUILayout.EndHorizontal(); + + GUILayout.Space(EditorGUIUtility.singleLineHeight); + + if (selectedLayers.Count == 1 && subLayerArray.arraySize != 0) + { + //ensure that selectedLayers[0] isn't out of bounds + if (selectedLayers[0] - layerTreeView.uniqueId > subLayerArray.arraySize - 1) + { + selectedLayers[0] = subLayerArray.arraySize - 1 + layerTreeView.uniqueId; + } + + SelectionIndex = selectedLayers[0]; + + var layerProperty = subLayerArray.GetArrayElementAtIndex(SelectionIndex - layerTreeView.uniqueId); + + layerProperty.isExpanded = true; + var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); + bool isLayerActive = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue; + if (!isLayerActive) + { + GUI.enabled = false; + } + + DrawLayerVisualizerProperties(sourceTypeValue, layerProperty, property); + if (!isLayerActive) + { + GUI.enabled = true; + } + } + else + { + GUILayout.Label("Select a visualizer to see properties"); + } + } + } + + void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty, SerializedProperty property) + { + var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); + GUILayout.Space(-_lineHeight); + GUILayout.Label(subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties"); + // V1 + EditorGUILayout.BeginVertical(); + EditorGUI.indentLevel++; + VectorPrimitiveType primitiveTypeProp = + (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex; + + GUILayout.Space(-_lineHeight); + 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; + + if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom) + { + EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("colliderOptions")); + GUILayout.Space(-_lineHeight); + EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("extrusionOptions")); + EditorGUI.indentLevel--; + EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions")); + EditorGUI.indentLevel++; + } + + EditorGUI.indentLevel--; + ShowOthers = EditorGUILayout.Foldout(ShowOthers, "Advanced"); + EditorGUI.indentLevel++; + if (ShowOthers) + { + if (primitiveTypeProp == VectorPrimitiveType.Polygon && sourceType != VectorSourceType.MapboxStreets) + { + EditorGUI.indentLevel--; + layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = true; + EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("buildingsWithUniqueIds"), new GUIContent + { + text = "Buildings With Unique Ids", + tooltip = + "Turn on this setting only when rendering 3D buildings from the Mapbox Streets with Building Ids tileset. Using this setting with any other polygon layers or source will result in visual artifacts. " + }); + EditorGUI.indentLevel++; + } + else + { + layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = false; + } + var filterOptions = layerProperty.FindPropertyRelative("filterOptions"); + filterOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue; + + EditorGUILayout.PropertyField(filterOptions, new GUIContent("Filters")); + DrawModifiers(layerProperty, new GUIContent { text = "Modifier Options", tooltip = "Additional Feature modifiers to apply to the visualizer. " }); + } + EditorGUILayout.EndVertical(); + EditorGUI.indentLevel--; + } + + void DrawModifiers(SerializedProperty property, GUIContent label) + { + var groupFeaturesProperty = property.FindPropertyRelative("coreOptions").FindPropertyRelative("groupFeatures"); + ShowPosition = EditorGUILayout.Foldout(ShowPosition, label.text); + EditorGUILayout.BeginVertical(); + if (ShowPosition) + { + EditorGUILayout.BeginHorizontal(); + if (groupFeaturesProperty.boolValue == false) + { + EditorGUILayout.PrefixLabel(new GUIContent + { + text = "Feature Position", + tooltip = "Position to place feature in the tile. " + }); + var featurePositionProperty = property.FindPropertyRelative("moveFeaturePositionTo"); + featurePositionProperty.enumValueIndex = EditorGUILayout.Popup(featurePositionProperty.enumValueIndex, + featurePositionProperty.enumDisplayNames); + } + + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(); + + EditorGUILayout.LabelField(new GUIContent + { + text = "Mesh Modifiers", + tooltip = "Modifiers that manipulate the features mesh. " + }); + + var meshfac = property.FindPropertyRelative("MeshModifiers"); + + for (int i = 0; i < meshfac.arraySize; i++) + { + var ind = i; + EditorGUILayout.BeginHorizontal(); + + EditorGUILayout.BeginVertical(); + meshfac.GetArrayElementAtIndex(ind).objectReferenceValue = + EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false) + as ScriptableObject; + + EditorGUILayout.EndVertical(); + + 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))) + { + meshfac.DeleteArrayElementAtIndex(ind); + } + + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.Space(); + EditorGUI.indentLevel++; + EditorGUILayout.BeginHorizontal(); + GUILayout.Space(EditorGUI.indentLevel * 12); + 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")) + { + ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac); + } + + EditorGUILayout.EndHorizontal(); + EditorGUI.indentLevel--; + EditorGUILayout.Space(); + EditorGUILayout.LabelField(new GUIContent + { + text = "Game Object Modifiers", + tooltip = "Modifiers that manipulate the GameObject after mesh generation." + }); + var gofac = property.FindPropertyRelative("GoModifiers"); + for (int i = 0; i < gofac.arraySize; i++) + { + var ind = i; + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.BeginVertical(); + GUILayout.Space(5); + gofac.GetArrayElementAtIndex(ind).objectReferenceValue = + EditorGUILayout.ObjectField(gofac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObjectModifier), + false) as ScriptableObject; + EditorGUILayout.EndVertical(); + + 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))) + { + gofac.DeleteArrayElementAtIndex(ind); + } + + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.Space(); + EditorGUI.indentLevel++; + EditorGUILayout.BeginHorizontal(); + GUILayout.Space(EditorGUI.indentLevel * 12); + 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")) + { + ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac); + } + + EditorGUILayout.EndHorizontal(); + EditorGUI.indentLevel--; + } + EditorGUILayout.EndVertical(); + } + + private void LoadEditorTileJSON(VectorSourceType sourceTypeValue, string sourceString) + { + if (sourceTypeValue != VectorSourceType.None && !string.IsNullOrEmpty(sourceString)) + { + if (tileJSONResponse == null || string.IsNullOrEmpty(TilesetId) || sourceString != TilesetId) + { + TilesetId = sourceString; + //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); + }); + } + else if (tileJSONData.LayerPropertyDescriptionDictionary.Count == 0) + { + tileJSONData.ProcessTileJSONData(tileJSONResponse); + } + + } + else + { + tileJSONData.ClearData(); + } + } + } +} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs index c5d058092..4e24aed57 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/GeometryExtrusionOptionsDrawer.cs @@ -79,34 +79,18 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten case Unity.Map.ExtrusionType.PropertyHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); DrawPropertyDropDown(property, position); - if (!dataUnavailable) - { - position.y += 2.5f * lineHeight; - } break; case Unity.Map.ExtrusionType.MinHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); DrawPropertyDropDown(property, position); - if (!dataUnavailable) - { - //position.y += 2.5f * lineHeight; - } break; case Unity.Map.ExtrusionType.MaxHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); DrawPropertyDropDown(property, position); - if (!dataUnavailable) - { - //position.y += 2.5f * lineHeight; - } break; case Unity.Map.ExtrusionType.RangeHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); DrawPropertyDropDown(property, position); - if (!dataUnavailable) - { - //position.y += 2.5f * lineHeight; - } EditorGUILayout.PropertyField(minHeightProperty); EditorGUILayout.PropertyField(maxHeightProperty); if (minHeightProperty.floatValue > maxHeightProperty.floatValue) @@ -166,25 +150,30 @@ private void DrawPropertyDropDown(SerializedProperty property, Rect position) private void DrawPropertyName(SerializedProperty property, Rect position, List propertyDisplayNames, string selectedLayerName) { propertyNamesList = propertyDisplayNames; + if (!_isLayerNameGUIContentSet) { _propertyNameContent = new GUIContent[propertyNamesList.Count]; for (int extIdx = 0; extIdx < propertyNamesList.Count; extIdx++) { + var parsedPropertyString = propertyNamesList[extIdx].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); _propertyNameContent[extIdx] = new GUIContent { text = propertyNamesList[extIdx], + tooltip = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedPropertyString] }; } _isLayerNameGUIContentSet = true; } + var propertyNameLabel = new GUIContent { text = "Property Name", tooltip = "The name of the property in the selected Mapbox layer that will be used for extrusion" }; index = EditorGUILayout.Popup(propertyNameLabel, index, _propertyNameContent); - //position.y += lineHeight; - var parsedString = propertyNamesList.ToArray()[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); + var parsedString = propertyNamesList[index].Split(new string[] { tileJsonData.optionalPropertiesString }, System.StringSplitOptions.None)[0].Trim(); + var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString]; + property.FindPropertyRelative("propertyName").stringValue = parsedString; - var descriptionString = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName][parsedString]; + EditorGUILayout.PrefixLabel(new GUIContent { text = "Property Description", tooltip = "Factual information about the selected property" }); EditorGUILayout.HelpBox(descriptionString, MessageType.Info); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs.meta b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs.meta deleted file mode 100644 index d52594b49..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 8b1e7d6ffe30243af9d1fbe886f180b1 -timeCreated: 1523475002 -licenseType: Pro -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs index d18424752..fb8c7ab8a 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/MapLocationOptionsDrawer.cs @@ -12,7 +12,7 @@ public class MapLocationOptionsDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.indentLevel++; - GUILayout.Space(-2f * _lineHeight); + GUILayout.Space(-1f * _lineHeight); EditorGUILayout.PropertyField(property.FindPropertyRelative("latitudeLongitude")); EditorGUILayout.PropertyField(property.FindPropertyRelative("zoom"), GUILayout.Height(_lineHeight)); EditorGUI.indentLevel--; diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PointsOfInterestSubLayerPropertiesDrawer.cs similarity index 81% rename from sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs rename to sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PointsOfInterestSubLayerPropertiesDrawer.cs index 30c74417d..53b9548f7 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/LocationPrefabsLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PointsOfInterestSubLayerPropertiesDrawer.cs @@ -1,145 +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) - { - 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); - } - } -} +namespace Mapbox.Unity.Map +{ + using UnityEngine; + using System.Collections.Generic; + using UnityEditor; + using Mapbox.Editor; + using UnityEditor.IMGUI.Controls; + using System.Linq; + + public class PointsOfInterestSubLayerPropertiesDrawer + { + string objectId = ""; + static float _lineHeight = EditorGUIUtility.singleLineHeight; + + PointsOfInterestSubLayerTreeView layerTreeView = new PointsOfInterestSubLayerTreeView(new TreeViewState()); + IList selectedLayers = new List(); + + int SelectionIndex + { + get + { + return EditorPrefs.GetInt(objectId + "LocationPrefabsLayerProperties_selectionIndex"); + } + set + { + EditorPrefs.SetInt(objectId + "LocationPrefabsLayerProperties_selectionIndex", value); + } + } + + public void DrawUI(SerializedProperty property) + { + objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); + var prefabItemArray = property.FindPropertyRelative("locationPrefabList"); + var layersRect = EditorGUILayout.GetControlRect(GUILayout.MinHeight(Mathf.Max(prefabItemArray.arraySize + 1, 1) * _lineHeight), + GUILayout.MaxHeight((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); + EditorGUILayout.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); + } + + EditorGUILayout.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/PrefabItemOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs index dd7cb8d81..52312bfbc 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/PrefabItemOptionsDrawer.cs @@ -54,7 +54,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten GUILayout.Label(prefabItemCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties"); //Prefab Game Object - GUILayout.Space(-_lineHeight); EditorGUI.indentLevel++; var spawnPrefabOptions = property.FindPropertyRelative("spawnPrefabOptions"); EditorGUILayout.PropertyField(spawnPrefabOptions); diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs index db309a088..0c318ff39 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/SpawnPrefabOptionsDrawer.cs @@ -25,13 +25,17 @@ public class SpawnPrefabOptionsDrawer : PropertyDrawer public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUILayout.PropertyField(property.FindPropertyRelative("prefab"), prefabContent); - EditorGUILayout.PropertyField(property.FindPropertyRelative("scaleDownWithWorld"), scalePrefabContent); + 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; - //} + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + return 2.0f * lineHeight; + } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs index 1cc770f7c..e40327516 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorFilterOptionsDrawer.cs @@ -39,10 +39,8 @@ int propertyIndex public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); - EditorGUI.BeginProperty(position, label, property); - position.height = lineHeight; - showFilters = EditorGUI.Foldout(position, showFilters, new GUIContent { text = "Filters", tooltip = "Filter features in a vector layer based on criterion specified. " }); + showFilters = EditorGUILayout.Foldout(showFilters, new GUIContent { text = "Filters", tooltip = "Filter features in a vector layer based on criterion specified. " }); if (showFilters) { var propertyFilters = property.FindPropertyRelative("filters"); @@ -65,8 +63,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } - - EditorGUI.EndProperty(); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { @@ -174,7 +170,7 @@ private void DrawPropertyDropDown(SerializedProperty originalProperty, Serialize descriptionArray = tileJsonData.LayerPropertyDescriptionDictionary[selectedLayerName].Values.ToArray(); GUIContent[] properties = new GUIContent[propertyDisplayNames.Count]; - for (int i = 0; i< propertyDisplayNames.Count; i++) + for (int i = 0; i < propertyDisplayNames.Count; i++) { properties[i] = new GUIContent(propertyDisplayNames[i], descriptionArray[i]); } @@ -217,4 +213,4 @@ private void DrawWarningMessage() // } //} -} \ 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 9aa93332b..545c8d5bc 100644 --- a/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs +++ b/sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/VectorLayerPropertiesDrawer.cs @@ -1,547 +1,100 @@ namespace Mapbox.Editor { using System; - using System.Collections.Generic; - using System.Linq; using UnityEngine; using UnityEditor; using Mapbox.Unity.Map; - using UnityEditor.IMGUI.Controls; - 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 { - static float _lineHeight = EditorGUIUtility.singleLineHeight; - GUIContent[] _sourceTypeContent; - bool _isGUIContentSet = false; - bool _isInitialized = false; - private TileJsonData tileJSONData; - private static TileJSONResponse tileJSONResponse; + private string objectId = ""; /// - /// Gets or sets the layerID + /// Gets or sets a value to show or hide Vector section . /// - /// true then show general section; otherwise hide, false. - - string objectId = ""; - private string TilesetId + /// true if show vector; otherwise, false. + bool ShowLocationPrefabs { get { - return EditorPrefs.GetString(objectId + "MapManagerEditor_tilesetId"); + return EditorPrefs.GetBool(objectId + "VectorLayerProperties_showLocationPrefabs"); } set { - EditorPrefs.SetString(objectId + "MapManagerEditor_tilesetId", value); + EditorPrefs.SetBool(objectId + "VectorLayerProperties_showLocationPrefabs", value); } } - bool ShowPosition + /// + /// Gets or sets a value to show or hide Vector section . + /// + /// true if show vector; otherwise, false. + bool ShowFeatures { get { - return EditorPrefs.GetBool(objectId + "VectorLayerProperties_showPosition"); + return EditorPrefs.GetBool(objectId + "VectorLayerProperties_showFeatures"); } set { - EditorPrefs.SetBool(objectId + "VectorLayerProperties_showPosition", value); + EditorPrefs.SetBool(objectId + "VectorLayerProperties_showFeatures", value); } } - bool ShowOthers + private GUIContent _requiredMapIdGui = new GUIContent { - get - { - return EditorPrefs.GetBool(objectId + "VectorLayerProperties_showOthers"); - } - set - { - EditorPrefs.SetBool(objectId + "VectorLayerProperties_showOthers", value); - } - } + text = "Required Map Id", + tooltip = "For location prefabs to spawn the \"streets-v7\" tileset needs to be a part of the Vector data source" + }; - int SelectionIndex - { - get - { - return EditorPrefs.GetInt(objectId + "VectorLayerProperties_selectionIndex"); - } - set - { - EditorPrefs.SetInt(objectId + "VectorLayerProperties_selectionIndex", value); - } - } + FeaturesSubLayerPropertiesDrawer _vectorSublayerDrawer = new FeaturesSubLayerPropertiesDrawer(); + PointsOfInterestSubLayerPropertiesDrawer _poiSublayerDrawer = new PointsOfInterestSubLayerPropertiesDrawer(); - string CustomSourceMapId + void ShowSepartor() { - get - { - return EditorPrefs.GetString(objectId + "VectorLayerProperties_customSourceMapId"); - } - set - { - EditorPrefs.SetString(objectId + "VectorLayerProperties_customSourceMapId", value); - } + EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); + EditorGUILayout.Space(); } - VectorSubLayerTreeView layerTreeView = new VectorSubLayerTreeView(new TreeViewState()); - IList selectedLayers = new List(); - - private GUIContent _mapIdGui = new GUIContent - { - text = "Map Id", - tooltip = "Map Id corresponding to the tileset." - }; - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + EditorGUI.BeginProperty(position, null, property); objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); - var serializedMapObject = property.serializedObject; - AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; - tileJSONData = mapObject.VectorData.LayerProperty.tileJsonData; + var layerSourceProperty = property.FindPropertyRelative("sourceOptions"); var sourceTypeProperty = property.FindPropertyRelative("_sourceType"); - var sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; + VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; + string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; + var layerSourceId = layerSourceProperty.FindPropertyRelative("layerSource.Id"); + string layerString = layerSourceId.stringValue; - 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 sourceTypeLabel = (new GUIContent { text = "Data Source", tooltip = "Source tileset for Vector Data" }); - - //sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, _sourceTypeContent); - sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; + //Draw POI Section - var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); - var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); - var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); - var isActiveProperty = sourceOptionsProperty.FindPropertyRelative("isActive"); - switch (sourceTypeValue) + ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST"); + if (ShowLocationPrefabs) { - case VectorSourceType.MapboxStreets: - case VectorSourceType.MapboxStreetsWithBuildingIds: - var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue); - layerSourceId.stringValue = sourcePropertyValue.Id; + if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7)) + { GUI.enabled = false; - //EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); - if (_isInitialized) - { - LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); - } - else - { - _isInitialized = true; - } - if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded) - { - EditorGUILayout.HelpBox("Invalid Map Id / There might be a problem with the internet connection.", MessageType.Error); - } + EditorGUILayout.TextField(_requiredMapIdGui, streets_v7); GUI.enabled = true; - isActiveProperty.boolValue = true; - break; - case VectorSourceType.Custom: - layerSourceId.stringValue = CustomSourceMapId; - //EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); - if (_isInitialized) - { - LoadEditorTileJSON(sourceTypeValue, layerSourceId.stringValue); - } - else - { - _isInitialized = true; - } - if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded) - { - 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: - isActiveProperty.boolValue = false; - break; - default: - isActiveProperty.boolValue = false; - break; - } - //EditorGUI.BeginProperty(position, label, property); - //position.height = _lineHeight; - - GUILayout.Space(-_lineHeight); - - if (sourceTypeValue != VectorSourceType.None) - { - EditorGUILayout.LabelField(new GUIContent - { - text = "Vector Layer Visualizers", - tooltip = "Visualizers for vector features contained in a layer. " - }); - - var subLayerArray = property.FindPropertyRelative("vectorSubLayers"); - 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. - //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] > subLayerArray.arraySize - 1) - { - selectedLayers[0] = subLayerArray.arraySize - 1; - } - - SelectionIndex = selectedLayers[0]; - + _poiSublayerDrawer.DrawUI(property); } else { - selectedLayers = new int[1] { SelectionIndex }; - if (SelectionIndex > 0 && (SelectionIndex <= subLayerArray.arraySize - 1)) - { - layerTreeView.SetSelection(selectedLayers); - } - } - - GUILayout.Space(EditorGUIUtility.singleLineHeight); - - GUILayout.BeginHorizontal(); - - if (GUILayout.Button(new GUIContent("Add Visualizer"), (GUIStyle)"minibuttonleft")) - { - subLayerArray.arraySize++; - //subLayerArray.InsertArrayElementAtIndex(subLayerArray.arraySize); - - var subLayer = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1); - var subLayerName = subLayer.FindPropertyRelative("coreOptions.sublayerName"); - - subLayerName.stringValue = "Untitled"; - - // Set defaults here because SerializedProperty copies the previous element. - var subLayerCoreOptions = subLayer.FindPropertyRelative("coreOptions"); - subLayerCoreOptions.FindPropertyRelative("isActive").boolValue = true; - subLayerCoreOptions.FindPropertyRelative("layerName").stringValue = "building"; - 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("extrusionGeometryType").enumValueIndex = - (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; - - 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; - - subLayer.FindPropertyRelative("buildingsWithUniqueIds").boolValue = false; - 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; - - selectedLayers = new int[1] { subLayerArray.arraySize - 1 }; - layerTreeView.SetSelection(selectedLayers); - } - - if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright")) - { - foreach (var index in selectedLayers.OrderByDescending(i => i)) - { - subLayerArray.DeleteArrayElementAtIndex(index); - } - - selectedLayers = new int[0]; - layerTreeView.SetSelection(selectedLayers); - } - - GUILayout.EndHorizontal(); - - GUILayout.Space(EditorGUIUtility.singleLineHeight); - - if (selectedLayers.Count == 1 && subLayerArray.arraySize != 0) - { - //ensure that selectedLayers[0] isn't out of bounds - if (selectedLayers[0] > subLayerArray.arraySize - 1) - { - selectedLayers[0] = subLayerArray.arraySize - 1; - } - - SelectionIndex = selectedLayers[0]; - - var layerProperty = subLayerArray.GetArrayElementAtIndex(SelectionIndex); - - layerProperty.isExpanded = true; - var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); - bool isLayerActive = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue; - if (!isLayerActive) - { - GUI.enabled = false; - } - - DrawLayerVisualizerProperties(sourceTypeValue, layerProperty, property); - if (!isLayerActive) - { - GUI.enabled = true; - } - } - else - { - GUILayout.Label("Select a visualizer to see properties"); + EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source in the FEATURES section.", MessageType.Error); } } - //EditorGUI.EndProperty(); - } - - void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProperty layerProperty, SerializedProperty property) - { - var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions"); - GUILayout.Label(subLayerCoreOptions.FindPropertyRelative("sublayerName").stringValue + " Properties"); - GUILayout.BeginVertical(); - EditorGUI.indentLevel++; - VectorPrimitiveType primitiveTypeProp = - (VectorPrimitiveType)subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex; - - GUILayout.Space(-_lineHeight); - 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; + ShowSepartor(); - if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom) + //Draw Feature section. + ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES"); + if (ShowFeatures) { - GUILayout.Space(-_lineHeight); - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("colliderOptions")); - GUILayout.Space(-_lineHeight); - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("extrusionOptions")); - EditorGUI.indentLevel--; - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("materialOptions")); - EditorGUI.indentLevel++; - } - - EditorGUI.indentLevel--; - ShowOthers = EditorGUILayout.Foldout(ShowOthers, "Advanced"); - EditorGUI.indentLevel++; - if (ShowOthers) - { - if (primitiveTypeProp == VectorPrimitiveType.Polygon && sourceType != VectorSourceType.MapboxStreets) - { - EditorGUI.indentLevel--; - layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = true; - EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("buildingsWithUniqueIds"), new GUIContent - { - text = "Buildings With Unique Ids", - tooltip = - "Turn on this setting only when rendering 3D buildings from the Mapbox Streets with Building Ids tileset. Using this setting with any other polygon layers or source will result in visual artifacts. " - }); - EditorGUI.indentLevel++; - } - else - { - layerProperty.FindPropertyRelative("honorBuildingIdSetting").boolValue = false; - } - var filterOptions = layerProperty.FindPropertyRelative("filterOptions"); - 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. " }); - } - - EditorGUI.indentLevel--; - GUILayout.EndVertical(); - EditorGUI.indentLevel--; - EditorGUI.indentLevel++; - } - - void DrawModifiers(SerializedProperty property, GUIContent label) - { - var groupFeaturesProperty = property.FindPropertyRelative("coreOptions").FindPropertyRelative("groupFeatures"); - ShowPosition = EditorGUILayout.Foldout(ShowPosition, label.text); - EditorGUILayout.BeginVertical(); - if (ShowPosition) - { - EditorGUILayout.BeginHorizontal(); - if (groupFeaturesProperty.boolValue == false) - { - EditorGUILayout.PrefixLabel(new GUIContent - { - text = "Feature Position", - tooltip = "Position to place feature in the tile. " - }); - var featurePositionProperty = property.FindPropertyRelative("moveFeaturePositionTo"); - featurePositionProperty.enumValueIndex = EditorGUILayout.Popup(featurePositionProperty.enumValueIndex, - featurePositionProperty.enumDisplayNames); - } - - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.Space(); - - EditorGUILayout.LabelField(new GUIContent - { - text = "Mesh Modifiers", - tooltip = "Modifiers that manipulate the features mesh. " - }); - - var meshfac = property.FindPropertyRelative("MeshModifiers"); - - for (int i = 0; i < meshfac.arraySize; i++) - { - var ind = i; - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.BeginVertical(); - meshfac.GetArrayElementAtIndex(ind).objectReferenceValue = - EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false) - as ScriptableObject; - EditorGUILayout.EndVertical(); - 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))) - { - meshfac.DeleteArrayElementAtIndex(ind); - } - - EditorGUILayout.EndHorizontal(); - } - - EditorGUILayout.Space(); - EditorGUI.indentLevel++; - EditorGUILayout.BeginHorizontal(); - GUILayout.Space(EditorGUI.indentLevel * 12); - 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")) - { - ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac); - } - - EditorGUILayout.EndHorizontal(); - EditorGUI.indentLevel--; - EditorGUILayout.Space(); - EditorGUILayout.LabelField(new GUIContent - { - text = "Game Object Modifiers", - tooltip = "Modifiers that manipulate the GameObject after mesh generation." - }); - var gofac = property.FindPropertyRelative("GoModifiers"); - for (int i = 0; i < gofac.arraySize; i++) - { - var ind = i; - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.BeginVertical(); - GUILayout.Space(5); - gofac.GetArrayElementAtIndex(ind).objectReferenceValue = - EditorGUILayout.ObjectField(gofac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObjectModifier), - false) as ScriptableObject; - EditorGUILayout.EndVertical(); - - 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))) - { - gofac.DeleteArrayElementAtIndex(ind); - } - - EditorGUILayout.EndHorizontal(); - } - - EditorGUILayout.Space(); - EditorGUI.indentLevel++; - EditorGUILayout.BeginHorizontal(); - GUILayout.Space(EditorGUI.indentLevel * 12); - 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")) - { - ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac); - } - - EditorGUILayout.EndHorizontal(); - EditorGUI.indentLevel--; + _vectorSublayerDrawer.DrawUI(property); } - EditorGUILayout.EndVertical(); - } - private void LoadEditorTileJSON(VectorSourceType sourceTypeValue, string sourceString) - { - if (sourceTypeValue != VectorSourceType.None && !string.IsNullOrEmpty(sourceString)) - { - if (tileJSONResponse == null || string.IsNullOrEmpty(TilesetId) || sourceString != TilesetId) - { - TilesetId = sourceString; - //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); - }); - } - else if (tileJSONData.LayerPropertyDescriptionDictionary.Count == 0) - { - tileJSONData.ProcessTileJSONData(tileJSONResponse); - } - - } - else - { - tileJSONData.ClearData(); - } + EditorGUI.EndProperty(); } } } diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs deleted file mode 100644 index e7e88e6fc..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs +++ /dev/null @@ -1,74 +0,0 @@ -namespace Mapbox.Editor -{ - using System.Collections; - using System.Collections.Generic; - using UnityEngine; - using UnityEditor.IMGUI.Controls; - using UnityEditor; - using Mapbox.Unity.Map; - - public class VectorSubLayerTreeView : TreeView - { - public SerializedProperty Layers; - private float kToggleWidth = 18f; - - public VectorSubLayerTreeView(TreeViewState state) - : base(state) - { - showAlternatingRowBackgrounds = true; - showBorder = true; - Reload(); - } - - protected override TreeViewItem BuildRoot() - { - // The root item is required to have a depth of -1, and the rest of the items increment from that. - var root = new TreeViewItem { id = -1, depth = -1, displayName = "Root" }; - - var items = new List(); - var index = 0; - - if (Layers != null) - { - for (int i = 0; i < Layers.arraySize; i++) - { - var name = Layers.GetArrayElementAtIndex(i).FindPropertyRelative("coreOptions.sublayerName").stringValue; - items.Add(new TreeViewItem { id = index, depth = 1, displayName = name }); - index++; - } - } - - // Utility method that initializes the TreeViewItem.children and .parent for all items. - SetupParentsAndChildrenFromDepths(root, items); - - // Return root of the tree - return root; - } - - protected override bool CanRename(TreeViewItem item) - { - return true; - } - - protected override void RenameEnded(RenameEndedArgs args) - { - if (Layers == null) - { - return; - } - - var layer = Layers.GetArrayElementAtIndex(args.itemID); - layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = string.IsNullOrEmpty(args.newName.Trim()) ? args.originalName : args.newName; - } - - 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.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue; - base.RowGUI(args); - } - } -} diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs.meta b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs.meta deleted file mode 100644 index 0b224614d..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: a9591575401b14570a6a95b275639eaf -timeCreated: 1518069137 -licenseType: Pro -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/LocationPrefabLayerProperties.cs b/sdkproject/Assets/Mapbox/Unity/LayerProperties/LocationPrefabLayerProperties.cs deleted file mode 100644 index e971548c4..000000000 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/LocationPrefabLayerProperties.cs +++ /dev/null @@ -1,10 +0,0 @@ -using UnityEngine; -using System.Collections.Generic; -using Mapbox.Unity.Map; -using System; - -[Serializable] -public class LocationPrefabsLayerProperties : LayerProperties -{ - public List locationPrefabList = new List(); -} \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/LayerProperties/LocationPrefabLayerProperties.cs.meta b/sdkproject/Assets/Mapbox/Unity/LayerProperties/LocationPrefabLayerProperties.cs.meta deleted file mode 100644 index 88e490191..000000000 --- a/sdkproject/Assets/Mapbox/Unity/LayerProperties/LocationPrefabLayerProperties.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 3ee13521b77df4464a6e8571a5396a7d -timeCreated: 1523396148 -licenseType: Pro -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs b/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs index 8f473783d..d4d544818 100644 --- a/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs +++ b/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs @@ -241,7 +241,7 @@ private void CreateMeshes(UnityTile tile) { foreach (var builder in _layerBuilder[emptyLayer]) { - if(builder.Active) + if (builder.Active) { Progress++; //just pass the first available layer - we should create a static null layer for this diff --git a/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Modifiers/ModifierStack.cs b/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Modifiers/ModifierStack.cs index fb85f07ef..b213175b4 100644 --- a/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Modifiers/ModifierStack.cs +++ b/sdkproject/Assets/Mapbox/Unity/MeshGeneration/Modifiers/ModifierStack.cs @@ -181,7 +181,7 @@ public override GameObject Execute(UnityTile tile, VectorFeatureUnity feature, M _tempVectorEntity.Feature = feature; #if UNITY_EDITOR - if(feature.Data != null) + if (feature.Data != null) { _tempVectorEntity.GameObject.name = type + " - " + feature.Data.Id; } diff --git a/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs b/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs index 481400a09..5c1ed3f27 100644 --- a/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs +++ b/sdkproject/Assets/Mapbox/Unity/SourceLayers/VectorLayer.cs @@ -9,10 +9,6 @@ [Serializable] public class VectorLayer : IVectorDataLayer { - [SerializeField] - LocationPrefabsLayerProperties _locationPrefabsLayerProperties = new LocationPrefabsLayerProperties(); - - [SerializeField] VectorLayerProperties _layerProperty = new VectorLayerProperties(); @@ -109,26 +105,15 @@ public void AddVectorLayer(VectorSubLayerProperties 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) + if (PointsOfInterestSublayerList == null) { - _layerProperty.locationPrefabList = new List(); + PointsOfInterestSublayerList = new List(); } //add the prefab item if it doesn't already exist - if (!LocationPrefabsLayerProperties.locationPrefabList.Contains(prefabItem)) + if (!PointsOfInterestSublayerList.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); + PointsOfInterestSublayerList.Add(prefabItem); } } @@ -142,9 +127,9 @@ public void RemoveVectorLayer(int index) public void RemovePrefabItem(int index) { - if (LocationPrefabsLayerProperties.locationPrefabList != null) + if (PointsOfInterestSublayerList != null) { - LocationPrefabsLayerProperties.locationPrefabList.RemoveAt(index); + PointsOfInterestSublayerList.RemoveAt(index); } } @@ -158,7 +143,6 @@ public void Initialize(LayerProperties properties) public void Initialize() { _vectorTileFactory = ScriptableObject.CreateInstance(); - _layerProperty.locationPrefabList = LocationPrefabsLayerProperties.locationPrefabList; _vectorTileFactory.SetOptions(_layerProperty); } @@ -184,11 +168,15 @@ public VectorTileFactory Factory } private VectorTileFactory _vectorTileFactory; - public LocationPrefabsLayerProperties LocationPrefabsLayerProperties + public List PointsOfInterestSublayerList { get { - return _locationPrefabsLayerProperties; + return _layerProperty.locationPrefabList; + } + set + { + _layerProperty.locationPrefabList = value; } } }