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 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; PrefabModifier 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; } }