diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs b/sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs
index 0dc0f1c7e..18f722afa 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]
@@ -53,6 +54,23 @@ bool ShowTerrain
EditorPrefs.SetBool("MapManagerEditor_showTerrain", value);
}
}
+
+ ///
+ /// Gets or sets a value to 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 +91,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
{
@@ -98,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();
@@ -135,38 +168,107 @@ public override void OnInspectorGUI()
ShowSepartor();
- ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "LOCATION PREFABS");
- if (ShowLocationPrefabs)
+ 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 sourceType = layerProperty.FindPropertyRelative("_sourceType");
- VectorSourceType sourceTypeValue = (VectorSourceType)sourceType.enumValueIndex;
+ var sourceTypeProperty = layerProperty.FindPropertyRelative("_sourceType");
+ VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id;
- string layerString = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id").stringValue;
+ var layerSourceId = layerProperty.FindPropertyRelative("sourceOptions.layerSource.Id");
+ string layerString = layerSourceId.stringValue;
+ var isActiveProperty = layerSourceProperty.FindPropertyRelative("isActive");
- if(sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7))
+ var displayNames = sourceTypeProperty.enumDisplayNames;
+ int count = sourceTypeProperty.enumDisplayNames.Length;
+ if (!_isGUIContentSet)
{
- GUI.enabled = false;
- EditorGUILayout.TextField(_mapIdGui, streets_v7);
- GUI.enabled = true;
- ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties");
+ _sourceTypeContent = new GUIContent[count];
+ for (int extIdx = 0; extIdx < count; extIdx++)
+ {
+ _sourceTypeContent[extIdx] = new GUIContent
+ {
+ text = displayNames[extIdx],
+ tooltip = ((VectorSourceType)extIdx).Description(),
+ };
+ }
+
+ _isGUIContentSet = true;
}
- else
+
+ sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(new GUIContent
+ {
+ text = "Data Source",
+ tooltip = "Source tileset for Vector Data"
+ },sourceTypeProperty.enumValueIndex, _sourceTypeContent);
+
+ sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
+
+ switch (sourceTypeValue)
{
- EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source in the Vector section.",MessageType.Error);
+ 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;
}
- }
- ShowSepartor();
+ if (sourceTypeValue != VectorSourceType.None)
+ {
+ var isStyleOptimized = layerProperty.FindPropertyRelative("useOptimizedStyle");
+ EditorGUILayout.PropertyField(isStyleOptimized);
- ShowVector = EditorGUILayout.Foldout(ShowVector, "VECTOR");
- if (ShowVector)
- {
- ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty");
+ if (isStyleOptimized.boolValue)
+ {
+ EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("optimizedStyle"), new GUIContent("Style Options"));
+ }
+
+ EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("performanceOptions"), new GUIContent("Perfomance Options"));
+ }
+ EditorGUILayout.Space();
+ ShowSepartor();
+
+ ShowLocationPrefabs = EditorGUILayout.Foldout(ShowLocationPrefabs, "POINTS OF INTEREST");
+ if (ShowLocationPrefabs)
+ {
+ if (sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7))
+ {
+ GUI.enabled = false;
+ EditorGUILayout.TextField(_requiredMapIdGui, streets_v7);
+ GUI.enabled = true;
+ ShowSection(vectorDataProperty, "_locationPrefabsLayerProperties");
+ }
+ else
+ {
+ EditorGUILayout.HelpBox("In order to place location prefabs please add \"mapbox.mapbox-streets-v7\" to the data source.", MessageType.Error);
+ }
+ }
+ ShowSepartor();
+ ShowFeatures = EditorGUILayout.Foldout(ShowFeatures, "FEATURES");
+ if (ShowFeatures)
+ {
+ ShowSection(serializedObject.FindProperty("_vectorData"), "_layerProperty");
+ }
+ EditorGUI.indentLevel--;
}
GUILayout.EndVertical();
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 4eeb61d0f..c9bce3488 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");
@@ -84,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 48b4970b3..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",
@@ -144,12 +58,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.
@@ -280,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");
@@ -332,6 +245,7 @@ void DrawLayerVisualizerProperties(VectorSourceType sourceType, SerializedProper
EditorGUI.indentLevel--;
GUILayout.EndVertical();
EditorGUI.indentLevel--;
+ EditorGUI.indentLevel++;
}
void DrawModifiers(SerializedProperty property, GUIContent label)
diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs
index a3fa18b81..e20612878 100644
--- a/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs
+++ b/sdkproject/Assets/Mapbox/Unity/Editor/VectorSubLayerTreeView.cs
@@ -63,15 +63,14 @@ 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.item.displayName = item.FindPropertyRelative("coreOptions.sublayerName").stringValue;
-
base.RowGUI(args);
-
+ EditorGUI.indentLevel++;
}
}
}
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..481400a09 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,7 @@ 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);
- }
- }
- }
+ _layerProperty.locationPrefabList = LocationPrefabsLayerProperties.locationPrefabList;
_vectorTileFactory.SetOptions(_layerProperty);
}