Skip to content

Commit 044e660

Browse files
greglemonmapboxabhishektrip
authored andcommitted
Api ui integration vector texturing (#1031)
* add a proof of concept for partial layer updates * Replaced bare EditorHelper.CheckForModifiedProperty calls with EditorGUILayout.Popup-centric Begin/EndChangeCheck-encapsulated EditorHelper.CheckForModifiedProperty calls. * - Added property.serializedObject.Update() calls to beginning of OnGUI calls in vector-centric property drawers. - Wrapped CheckForModifiedProperty calls in EndChangeCheck conditional checks. Added color-coded debug message for Vector layer in AbstractMap. - Added System.EventHandler LayerVisualizerHasChanged and OnUpdateLayerVisualizer method to LayerVisualizerBase. - Added System.EventHandler TileFactoryHasChanged and UpdateTileFactory method to AbstractTileFactory. - Chain of EventHandlers = VectorLayerVisualizer -> VectorTileFactory -> VectorLayer -> AbstractMap * Temporarily disabled Vector Update business in abstract map. * Adding/removing mesh and/or gameplay modifiers now triggers change events. * Removed unused EndChangeCheck call in BehaviorModifiersSectionDrawer; moved tile factory update/change event vars/methods into events section. * Added support for change events in vector filter section. * Fix ui errors vector section (#1011) * Fix PropertyDrawer errors when adding new layer. * Fix errors on adding filters. * Removed commented/dead property.serializedObject.Update() calls. * Added UI update checks for Behavior Modifier section. * Removed unused delegate and method. * Removed property.serializedObject.Update call at beginning of OnGUI. * Adding/removing map features now triggers update event. * Enabling/disabling map feature checkboxes now fires UI update events. * Changing DataSource in map features section now triggers update. For some reason, this is not working with EditorHelper.CheckForModifiedProperty; setting HasChanged manually does work. * VectorUpdate is now working; map redraws vector section on vector-centric UI changes. - Sequential Vector UI changes will cause over/re-registration for event handlers. We need to fix this. - Added debug message and comment re: register/unregistering for EventHandlers... * hook terrain layer property to property changed event. * Use the variable to set collider. * Add helper methods * Add update methods to MapboxDataProperty * Use new methods in MapboxDataProperty. * Remove SerializedObject.update * Add ChangeCheck for Vector DataSource. * Add NeedsForceUpdate override * Switch to UpdateProperty * Change Active from field to Property. * Update signature for NotifyUpdateLayer * Add ChangeImagery method to test. * Add VectorLayerUpdateArgs + overload for NotifyUpdateLayer * Hook to UpdateTileFactory event * Add hooks to UpdateModifier Event * Add abstract SublayerProperty * Add UnregisterTilesFromLayer method * Add method to change texturing type. * Remove static MapboxDefaultStyle class. * Add event hookup to modifiers * Add layer args for vector layers * Add events for Add/Remove layer * Add events for modifiers. * Change HasChanged to virtual, add overrides * Add event hookup to modifiers * Code cleanup * Trigger Collider option change from UI * Add a method to re-intialize stack. * Clean out stacks before recreating the layer. * Add events to trigger SubLayerAdded from UI * Remove Layer API and hooks * Add missing property * Add function to unbind properties from modifier. * UpdateVector method now unbinds all modifiers. * remove SnapTerrain and CombineMeshes from points. * Add UpdateMap call to trigger when UI is changed. * extract lineGeometryOptions to its own class (with drawer) change line mesh modifier to use new lineGeometryOptions data container object add line feature event bindings to VectorLayerVisualizer * add update event support to poi layer * extract lineGeometryOptions to its own class (with drawer) change line mesh modifier to use new lineGeometryOptions data container object add line feature event bindings to VectorLayerVisualizer * add update event support to poi layer * fix a bug where prefab modifier rupdate event registration wasn't firing after an update * fix filtering poi category by none with a hacky solution * Remove hack with a fix for POILayer being set to None. * Add map update logic to General section UI events. * Add property to trigger separate events for extentType & Extent property change. * Property drawer changes for extentOptions * Add API methods for General Section functionality. * Add APi method for snapMapToZero. * add api methods to terrain and imagery layers * Fix typo. * Fix typo * add update system functionality to add/remove poi layers on data property change (#1022) * fix an issue where poi layer didn't create prefab modifier for name and latlng settings (#1028) * Vector Filter options API calls. * Added additional API methods. * Add multiple property methods (#1026) * add two SetProperties methods to terrain and image layer to set multiple properties at once * add comments to SetProperties methods * Move poi methods (#1023) * move poi api methods to vector layer add basic comments for terrain/image factory api methods * fix a broken method reference * change poi api methods to fire update events and work with runtime calls * Added API methods for interacting with texture style options. * Added API Get/Set methods and CustomStyleBundle class. * Removed duplicate methods in EditorHelper. Added comments and regions to API calls in VectorSubLayerProperties. * Marked all API methods as virtual. * Added VectorTextureApiTest. * Replaced new Material(material) calls with = material; renamed GetCustom___ methods to Get___ methods. * Wrapper for public interfaces * interface templates
1 parent 300a5d0 commit 044e660

File tree

6 files changed

+677
-17
lines changed

6 files changed

+677
-17
lines changed

sdkproject/Assets/ApiTest.cs

+103-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using Mapbox.Unity.Map;
55
using Mapbox.Unity.MeshGeneration.Interfaces;
6+
using Mapbox.Unity.MeshGeneration.Filters;
67
using UnityEngine;
78

89
public class ApiTest : MonoBehaviour
@@ -11,8 +12,17 @@ public class ApiTest : MonoBehaviour
1112
public ImagerySourceType imagerySource = ImagerySourceType.MapboxStreets;
1213

1314
public LocationPrefabCategories LocationPrefabCategories;
15+
public LayerFilterOperationType layerFilterOperationType;
1416
public GameObject PoiPrefab;
1517

18+
19+
public LayerFilterCombinerOperationType layerFilterCombinerOperationType;
20+
public string filterKey;
21+
22+
public float min;
23+
public float max;
24+
public string contains;
25+
1626
readonly StyleTypes[] testStyles = new StyleTypes[3] { StyleTypes.Fantasy, StyleTypes.Realistic, StyleTypes.Simple };
1727
int styleId = -1;
1828
void Start()
@@ -113,7 +123,7 @@ public void ChangeBuildingMaterial()
113123
var layer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("ExtrudedBuildings");
114124
if (layer != null)
115125
{
116-
layer.SetTexturingType(testStyles[styleId]);
126+
layer.SetStyleType(testStyles[styleId]);
117127
}
118128
else
119129
{
@@ -175,7 +185,6 @@ public void ChangePoiCategory()
175185
{
176186
var pois = _abstractMap.VectorData.LayerProperty.FindPoiLayerWithName("loc");
177187
pois.categories = LocationPrefabCategories;
178-
Debug.Log("ChangePoiCategory ---> " + pois.GetType().ToString()); //PrefabItemOptions
179188
pois.HasChanged = true;
180189
}
181190

@@ -184,7 +193,6 @@ public void ChangePoiPrefab()
184193
{
185194
var pois = _abstractMap.VectorData.LayerProperty.FindPoiLayerWithName("loc");
186195
pois.spawnPrefabOptions.prefab = PoiPrefab;
187-
Debug.Log("ChangePoiPrefab ---> " + pois.spawnPrefabOptions.GetType().ToString());//SpawnPrefabOptions
188196
pois.spawnPrefabOptions.HasChanged = true;
189197
}
190198

@@ -194,7 +202,6 @@ public void ChangeToPoiByName()
194202
var pois = _abstractMap.VectorData.LayerProperty.FindPoiLayerWithName("loc");
195203
pois.findByType = LocationPrefabFindBy.POIName;
196204
pois.nameString = "yerba";
197-
Debug.Log("ChangeToPoiByName ---> " + pois.GetType().ToString());//PrefabItemOptions
198205
pois.HasChanged = true;
199206
}
200207

@@ -203,10 +210,101 @@ public void ChangeToCategory()
203210
{
204211
var pois = _abstractMap.VectorData.LayerProperty.FindPoiLayerWithName("loc");
205212
pois.findByType = LocationPrefabFindBy.MapboxCategory;
206-
Debug.Log("ChangeToCategory ---> " + pois.GetType().ToString());//PrefabItemOptions
207213
pois.HasChanged = true;
208214
}
209215

216+
[ContextMenu("Vector - Add New Filter")]
217+
public void AddNewFilter()
218+
{
219+
var vectorLayer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("loc");
220+
LayerFilter layerFilter = new LayerFilter(LayerFilterOperationType.Contains);
221+
vectorLayer.filterOptions.filters.Add(layerFilter);
222+
vectorLayer.filterOptions.HasChanged = true;
223+
}
224+
225+
[ContextMenu("Vector - Remove Filter")]
226+
public void RemoveFilter()
227+
{
228+
int index = 0;
229+
var vectorLayer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("loc");
230+
if(index < vectorLayer.filterOptions.filters.Count)
231+
{
232+
vectorLayer.filterOptions.filters.RemoveAt(index);
233+
}
234+
vectorLayer.filterOptions.HasChanged = true;
235+
}
236+
237+
[ContextMenu("Vector - Set Filter Combiner Type")]
238+
public void SetFilterCombinerType()
239+
{
240+
var vectorLayer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("loc");
241+
242+
vectorLayer.filterOptions.combinerType = layerFilterCombinerOperationType;
243+
244+
vectorLayer.filterOptions.HasChanged = true;
245+
}
246+
247+
[ContextMenu("Vector - Set Filter Key")]
248+
public void SetFilterKey()
249+
{
250+
int index = 0;
251+
var vectorLayer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("loc");
252+
if (index < vectorLayer.filterOptions.filters.Count)
253+
{
254+
vectorLayer.filterOptions.filters[index].Key = filterKey;
255+
}
256+
vectorLayer.filterOptions.HasChanged = true;
257+
}
258+
259+
[ContextMenu("Vector - Set Filter Operator")]
260+
public void SetFilterOperator()
261+
{
262+
int index = 0;
263+
var vectorLayer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("loc");
264+
if (index < vectorLayer.filterOptions.filters.Count)
265+
{
266+
vectorLayer.filterOptions.filters[index].filterOperator = layerFilterOperationType;
267+
}
268+
vectorLayer.filterOptions.HasChanged = true;
269+
}
270+
271+
[ContextMenu("Vector - Set Filter Min Value")]
272+
public void SetFilterCompareValue()
273+
{
274+
int index = 0;
275+
var vectorLayer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("loc");
276+
if (index < vectorLayer.filterOptions.filters.Count)
277+
{
278+
vectorLayer.filterOptions.filters[index].Min = min;
279+
}
280+
vectorLayer.filterOptions.HasChanged = true;
281+
}
282+
283+
[ContextMenu("Vector - Set Filter Compare MinMaxValue")]
284+
public void SetFilterCompareMinMaxValue()
285+
{
286+
int index = 0;
287+
var vectorLayer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("loc");
288+
if (index < vectorLayer.filterOptions.filters.Count)
289+
{
290+
vectorLayer.filterOptions.filters[index].Min = min;
291+
vectorLayer.filterOptions.filters[index].Max = max;
292+
}
293+
vectorLayer.filterOptions.HasChanged = true;
294+
}
295+
296+
[ContextMenu("Vector - Set Filter Contains Value")]
297+
public void SetFilterContainsValue()
298+
{
299+
int index = 0;
300+
var vectorLayer = _abstractMap.VectorData.LayerProperty.FindFeatureLayerWithName("loc");
301+
if (index < vectorLayer.filterOptions.filters.Count)
302+
{
303+
vectorLayer.filterOptions.filters[index].PropertyValue = contains;
304+
}
305+
vectorLayer.filterOptions.HasChanged = true;
306+
}
307+
210308
[ContextMenu("TestPoiCategoryApi")]
211309
public void TestPoiCategoryApi()
212310
{

sdkproject/Assets/Mapbox/Unity/DataContainers/GeometryMaterialOptions.cs

+15-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,17 @@
77
using Mapbox.Unity.MeshGeneration.Modifiers;
88
using Mapbox.Unity.MeshGeneration.Data;
99

10+
public class CustomStyleBundle
11+
{
12+
public Material topMaterial;
13+
public Material sideMaterial;
14+
public AtlasInfo atlasInfo;
15+
public ScriptablePalette colorPalette;
16+
}
17+
1018
[Serializable]
11-
public class GeometryMaterialOptions : ModifierProperties
19+
public class GeometryMaterialOptions : ModifierProperties, ISubLayerTexturing
20+
1221
{
1322
public override Type ModifierType
1423
{
@@ -128,6 +137,11 @@ public void SetDefaultAssets()
128137
texturingType = UvMapType.Atlas;
129138
AssignAssets(styleAssetPathBundle);
130139
}
140+
141+
public void SetDefaultStyleType(StyleTypes style)
142+
{
143+
throw new NotImplementedException();
144+
}
131145
}
132146

133147
[Serializable]

0 commit comments

Comments
 (0)