public void PostProcessLayerProperties(SerializedProperty property) { var layerSourceProperty = property.FindPropertyRelative("sourceOptions"); var sourceTypeProperty = property.FindPropertyRelative("_sourceType"); VectorSourceType sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex; string streets_v7 = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets).Id; var layerSourceId = layerSourceProperty.FindPropertyRelative("layerSource.Id"); string layerString = layerSourceId.stringValue; if (ShowLocationPrefabs) { if (_poiSublayerDrawer.isLayerAdded == true && sourceTypeValue != VectorSourceType.None && layerString.Contains(streets_v7)) { var prefabItemArray = property.FindPropertyRelative("locationPrefabList"); var prefabItem = prefabItemArray.GetArrayElementAtIndex(prefabItemArray.arraySize - 1); PrefabItemOptions prefabItemOptionToAdd = (PrefabItemOptions)EditorHelper.GetTargetObjectOfProperty(prefabItem) as PrefabItemOptions; ((VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property)).OnSubLayerPropertyAdded(new VectorLayerUpdateArgs { property = prefabItemOptionToAdd }); _poiSublayerDrawer.isLayerAdded = false; } } if (ShowFeatures) { if (_vectorSublayerDrawer.isLayerAdded == true) { var subLayerArray = property.FindPropertyRelative("vectorSubLayers"); var subLayer = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1); ((VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property)).OnSubLayerPropertyAdded(new VectorLayerUpdateArgs { property = EditorHelper.GetTargetObjectOfProperty(subLayer) as MapboxDataProperty }); _vectorSublayerDrawer.isLayerAdded = false; } } }
public virtual LayerVisualizerBase AddPOIVectorLayerVisualizer(PrefabItemOptions poiSubLayer) { LayerVisualizerBase visualizer = CreateInstance <LocationPrefabsLayerVisualizer>(); poiSubLayer.performanceOptions = _properties.performanceOptions; ((LocationPrefabsLayerVisualizer)visualizer).SetProperties((PrefabItemOptions)poiSubLayer); visualizer.LayerVisualizerHasChanged += UpdateTileFactory; visualizer.Initialize(); if (visualizer == null) { return(null); } if (_layerBuilder.ContainsKey(visualizer.Key)) { _layerBuilder[visualizer.Key].Add(visualizer); } else { _layerBuilder.Add(visualizer.Key, new List <LayerVisualizerBase>() { visualizer }); } return(visualizer); }
/// <summary> /// Merges the filters with item filters. /// </summary> /// <param name="item">Item.</param> private void AddFilterToItem(PrefabItemOptions item, LayerFilter filter) { if (item.filterOptions == null) { item.filterOptions = new VectorFilterOptions(); } item.filterOptions.filters.Add(filter); item.filterOptions.combinerType = item._combinerType; }
public void AddPoiLayer() { var prefabItemOptions = new PrefabItemOptions(); prefabItemOptions.categories = LocationPrefabCategories; prefabItemOptions.spawnPrefabOptions = new SpawnPrefabOptions(); prefabItemOptions.spawnPrefabOptions.prefab = PoiPrefab; _abstractMap.VectorData.AddPointsOfInterestSubLayer(prefabItemOptions); }
/// <summary> /// Sets the density filters. /// </summary> /// <param name="item">Item.</param> private void SetDensityFilters(PrefabItemOptions item) { if (item.density >= maxDensity) // decided that the max value for density { return; } string propertyName = ""; item.densityPropertyFromFindByTypeDictionary.TryGetValue(item.findByType, out propertyName); if (item.findByType == LocationPrefabFindBy.MapboxCategory || item.findByType == LocationPrefabFindBy.POIName) { LayerFilter filter = new LayerFilter(LayerFilterOperationType.IsLess) { Key = propertyName, Min = item.density }; AddFilterToItem(item, filter); } }
/// <summary> /// Sets the name filters. /// </summary> /// <param name="item">Item.</param> private void SetNameFilters(PrefabItemOptions item) { if (string.IsNullOrEmpty(item.nameString)) { return; } string propertyName = ""; item.namePropertyFromFindByTypeDictionary.TryGetValue(item.findByType, out propertyName); if (item.findByType == LocationPrefabFindBy.POIName) { LayerFilter filter = new LayerFilter(LayerFilterOperationType.Contains) { Key = propertyName, PropertyValue = item.nameString }; AddFilterToItem(item, filter); } }
/// <summary> /// Sets the category filter options. /// </summary> /// <param name="item">Item.</param> private void SetCategoryFilterOptions(PrefabItemOptions item) { string propertyName = ""; item.categoryPropertyFromFindByTypeDictionary.TryGetValue(item.findByType, out propertyName); string concatenatedString = ""; if (item.findByType == LocationPrefabFindBy.MapboxCategory) { List <LocationPrefabCategories> categoriesList = GetSelectedCategoriesList(item.categories); if (categoriesList == null || categoriesList.Count == 0) { return; } else { List <string> stringsList = new List <string>(); foreach (LocationPrefabCategories category in categoriesList) { stringsList = LocationPrefabCategoryOptions.GetMakiListFromCategory(category); if (string.IsNullOrEmpty(concatenatedString)) { concatenatedString = string.Join(",", stringsList.ToArray()); } else { concatenatedString += "," + string.Join(",", stringsList.ToArray()); } } LayerFilter filter = new LayerFilter(LayerFilterOperationType.Contains) { Key = propertyName, PropertyValue = concatenatedString }; AddFilterToItem(item, filter); } } }
public override void SetProperties(VectorSubLayerProperties properties) { var item = properties as PrefabItemOptions; SubLayerProperties = item; _performanceOptions = item.performanceOptions; item.filterOptions.filters.Clear(); //These are fixed properties item.coreOptions.geometryType = item.primitiveType; item.extrusionOptions = new GeometryExtrusionOptions { extrusionType = item.extrusionType }; item.coreOptions.combineMeshes = item.combineMeshes; item.moveFeaturePositionTo = item._movePrefabFeaturePositionTo; string layerName = ""; if (item.layerNameFromFindByTypeDictionary.TryGetValue(item.findByType, out layerName)) { item.coreOptions.layerName = layerName; base.Key = layerName; } if (item.spawnPrefabOptions.prefab == null) { item.spawnPrefabOptions.prefab = Resources.Load <GameObject>("MapboxPin"); Debug.LogWarning("No prefab assigned for POI Layer - " + layerName + " , using default prefab! You may want to assign a custom prefab."); } //These properties are dependent on user choices if (item.findByType != LocationPrefabFindBy.AddressOrLatLon) { if (item.findByType == LocationPrefabFindBy.MapboxCategory) { SetCategoryFilterOptions(item); } if (item.findByType == LocationPrefabFindBy.POIName) { SetNameFilters(item); } SetDensityFilters(item); } switch (item.coreOptions.geometryType) { case VectorPrimitiveType.Point: #if ENABLE_WINMD_SUPPORT if (typeof(PrefabItemOptions).GetTypeInfo().IsAssignableFrom(item.GetType().GetTypeInfo())) //to check that the instance is of type PrefabItemOptions #else if (typeof(PrefabItemOptions).IsAssignableFrom(item.GetType())) //to check that the instance is of type PrefabItemOptions #endif { PrefabItemOptions itemProperties = (PrefabItemOptions)item; if (_defaultStack == null) { _defaultStack = ScriptableObject.CreateInstance <ModifierStack>(); } (_defaultStack as ModifierStack).moveFeaturePositionTo = item.moveFeaturePositionTo; if (itemProperties.snapToTerrain == true) { AddOrCreateMeshModifier <SnapTerrainModifier>(); } if (_defaultStack.GoModifiers == null) { _defaultStack.GoModifiers = new List <GameObjectModifier>(); } if (item.findByType == LocationPrefabFindBy.MapboxCategory) { if (_prefabModifier != null) { _prefabModifier.Clear(); } _defaultStack.GoModifiers.Clear(); } if ((item.findByType == LocationPrefabFindBy.MapboxCategory && item.categories == LocationPrefabCategories.None)) { itemProperties.spawnPrefabOptions.PropertyHasChanged += UpdatePois; } else { _prefabModifier = AddOrCreateGameObjectModifier <PrefabModifier>(); _prefabModifier.SetProperties(itemProperties.spawnPrefabOptions); _prefabModifier.ModifierHasChanged += UpdatePois; } } break; default: break; } item.coreOptions.PropertyHasChanged += UpdatePois; (SubLayerProperties as PrefabItemOptions).PropertyHasChanged += UpdatePois; }
private int maxDensity = 30; //This value is same as the density's max range value in PrefabItemOptions public void SetProperties(PrefabItemOptions item) { SubLayerProperties = item; Active = item.isActive; _performanceOptions = item.performanceOptions; //Check to make sure that when Categories selection is none, the location prefab is disabled if (item.findByType == LocationPrefabFindBy.MapboxCategory && item.categories == LocationPrefabCategories.None) { return; } if (item.spawnPrefabOptions.prefab == null) { Debug.LogError("No prefab found. Please assign a prefab to spawn it on the map"); } //These are fixed properties item.coreOptions.geometryType = item.primitiveType; item.extrusionOptions = new GeometryExtrusionOptions { extrusionType = item.extrusionType }; item.coreOptions.combineMeshes = item.combineMeshes; item.moveFeaturePositionTo = item._movePrefabFeaturePositionTo; string layerName = ""; if (item.layerNameFromFindByTypeDictionary.TryGetValue(item.findByType, out layerName)) { item.coreOptions.layerName = layerName; base.Key = layerName; } //These properties are dependent on user choices if (item.findByType != LocationPrefabFindBy.AddressOrLatLon) { if (item.findByType == LocationPrefabFindBy.MapboxCategory) { SetCategoryFilterOptions(item); } if (item.findByType == LocationPrefabFindBy.POIName) { SetNameFilters(item); } SetDensityFilters(item); } switch (item.coreOptions.geometryType) { case VectorPrimitiveType.Point: if (typeof(PrefabItemOptions).IsAssignableFrom(item.GetType())) //to check that the instance is of type PrefabItemOptions { var itemProperties = (PrefabItemOptions)item; var prefabModifier = ScriptableObject.CreateInstance <PrefabModifier>(); prefabModifier.SetProperties(itemProperties.spawnPrefabOptions); _defaultStack = ScriptableObject.CreateInstance <ModifierStack>(); (_defaultStack as ModifierStack).moveFeaturePositionTo = item.moveFeaturePositionTo; if (_defaultStack.GoModifiers == null) { _defaultStack.GoModifiers = new List <GameObjectModifier>(); } _defaultStack.GoModifiers.Add(prefabModifier); if (itemProperties.snapToTerrain == true) { _defaultStack.MeshModifiers.Add(ScriptableObject.CreateInstance <SnapTerrainModifier>()); } } break; default: break; } }