protected override void OnRegistered(UnityTile tile) { if (_properties.sourceType == ImagerySourceType.None) { tile.SetRasterData(null); tile.RasterDataState = TilePropertyState.None; return; } else { tile.RasterDataState = TilePropertyState.Loading; if (_properties.sourceType != ImagerySourceType.Custom) { _properties.sourceOptions.layerSource = MapboxDefaultImagery.GetParameters(_properties.sourceType); } ImageDataFetcherParameters parameters = new ImageDataFetcherParameters() { canonicalTileId = tile.CanonicalTileId, tile = tile, mapid = MapId, useRetina = _properties.rasterOptions.useRetina }; DataFetcher.FetchData(parameters); } }
public TerrainImageFactory(TerrainCompletion completionCallback = null) { AllImagesLoaded += completionCallback; _dataFetcher = ScriptableObject.CreateInstance <TerrainImageFetcher>(); _dataFetcher.dataReceived += OnImageReceived; Properties = new ImageryLayerProperties { sourceType = ImagerySourceType.Custom, sourceOptions = new LayerSourceOptions { isActive = true, layerSource = MapboxDefaultImagery.GetParameters(ImagerySourceType.MapboxStreets), Id = "mapbox://styles/jw5514/cjr7loico0my12rnrzcm9qk2p" }, rasterOptions = new ImageryRasterOptions { useCompression = true } }; var tilesCount = ManhattanTileProvider.Tiles.Count; _textures = new Texture2D[tilesCount]; _combineInstances = new CombineInstance[tilesCount]; _textureArray = new Texture2DArray(512, 512, _textures.Length, TextureFormat.RGB24, false); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); position.height = lineHeight; // Draw label. var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Style Name", tooltip = EnumExtensions.Description(sourceTypeValue) }); sourceTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, sourceTypeProperty.enumValueIndex, sourceTypeProperty.enumDisplayNames); sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; position.y += lineHeight; switch (sourceTypeValue) { case ImagerySourceType.MapboxStreets: case ImagerySourceType.MapboxOutdoors: case ImagerySourceType.MapboxDark: case ImagerySourceType.MapboxLight: case ImagerySourceType.MapboxSatellite: case ImagerySourceType.MapboxSatelliteStreet: var sourcePropertyValue = MapboxDefaultImagery.GetParameters(sourceTypeValue); var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; EditorGUI.PropertyField(position, sourceOptionsProperty); GUI.enabled = true; break; case ImagerySourceType.Custom: EditorGUI.PropertyField(position, property.FindPropertyRelative("sourceOptions"), new GUIContent("Source Options")); break; case ImagerySourceType.None: break; default: break; } if (sourceTypeValue != ImagerySourceType.None) { position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); EditorGUI.PropertyField(position, property.FindPropertyRelative("rasterOptions")); } EditorGUI.EndProperty(); }
protected override void OnRegistered(CustomTile tile) { if (Properties.sourceType != ImagerySourceType.Custom) { Properties.sourceOptions.layerSource = MapboxDefaultImagery.GetParameters(Properties.sourceType); } var parameters = new TerrainImageFetcherParameters { canonicalTileId = tile.CanonicalTileId, tilesetId = TilesetId, cTile = tile, useRetina = Properties.rasterOptions.useRetina }; _dataFetcher.FetchData(parameters); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (ImagerySourceType)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 = EnumExtensions.Description((ImagerySourceType)extIdx), }; } isGUIContentSet = true; } // Draw label. var sourceTypeLabel = new GUIContent { text = "Data Source", tooltip = "Source tileset for Imagery." }; sourceTypeProperty.enumValueIndex = EditorGUILayout.Popup(sourceTypeLabel, sourceTypeProperty.enumValueIndex, sourceTypeContent); sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); switch (sourceTypeValue) { case ImagerySourceType.MapboxStreets: case ImagerySourceType.MapboxOutdoors: case ImagerySourceType.MapboxDark: case ImagerySourceType.MapboxLight: case ImagerySourceType.MapboxSatellite: case ImagerySourceType.MapboxSatelliteStreet: var sourcePropertyValue = MapboxDefaultImagery.GetParameters(sourceTypeValue); layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; EditorGUILayout.PropertyField(sourceOptionsProperty, _mapIdGui); GUI.enabled = true; break; case ImagerySourceType.Custom: EditorGUILayout.PropertyField(sourceOptionsProperty, new GUIContent { text = "Map Id / Style URL", tooltip = _mapIdGui.tooltip }); break; case ImagerySourceType.None: break; default: break; } if (sourceTypeValue != ImagerySourceType.None) { EditorGUILayout.PropertyField(property.FindPropertyRelative("rasterOptions")); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); position.height = lineHeight; var sourceTypeProperty = property.FindPropertyRelative("sourceType"); var sourceTypeValue = (ImagerySourceType)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 = ((ImagerySourceType)extIdx).Description(), }; } isGUIContentSet = true; } // Draw label. var typePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Data Source", tooltip = "Source tileset for Imagery." }); sourceTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, sourceTypeProperty.enumValueIndex, sourceTypeContent); sourceTypeValue = (ImagerySourceType)sourceTypeProperty.enumValueIndex; position.y += lineHeight; var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); switch (sourceTypeValue) { case ImagerySourceType.MapboxStreets: case ImagerySourceType.MapboxOutdoors: case ImagerySourceType.MapboxDark: case ImagerySourceType.MapboxLight: case ImagerySourceType.MapboxSatellite: case ImagerySourceType.MapboxSatelliteStreet: var sourcePropertyValue = MapboxDefaultImagery.GetParameters(sourceTypeValue); layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; EditorGUI.PropertyField(position, sourceOptionsProperty, _mapIdGui); GUI.enabled = true; break; case ImagerySourceType.Custom: layerSourceId.stringValue = CustomSourceMapId; EditorGUI.PropertyField(position, sourceOptionsProperty, new GUIContent { text = "Map Id / Style URL", tooltip = _mapIdGui.tooltip }); CustomSourceMapId = layerSourceId.stringValue; break; case ImagerySourceType.None: break; default: break; } if (sourceTypeValue != ImagerySourceType.None) { position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); EditorGUI.PropertyField(position, property.FindPropertyRelative("rasterOptions")); } EditorGUI.EndProperty(); }