public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var scalingType = property.FindPropertyRelative("scalingType"); var displayNames = scalingType.enumDisplayNames; int count = scalingType.enumDisplayNames.Length; if (!isGUIContentSet) { scalingTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { scalingTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((MapScalingType)extIdx), }; } isGUIContentSet = true; } // Draw label. var scalingTypeLabel = new GUIContent { text = label.text, tooltip = "Scale of map in game units.", }; scalingType.enumValueIndex = EditorGUILayout.Popup(scalingTypeLabel, scalingType.enumValueIndex, scalingTypeContent); if ((MapScalingType)scalingType.enumValueIndex == MapScalingType.Custom) { position.y += lineHeight; EditorGUILayout.PropertyField(property.FindPropertyRelative("unityTileSize")); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, null, property); var colliderTypeLabel = new GUIContent { text = "Collider Type", tooltip = "The type of collider added to game objects in this layer." }; var colliderTypeProperty = property.FindPropertyRelative("colliderType"); var displayNames = colliderTypeProperty.enumDisplayNames; int count = colliderTypeProperty.enumDisplayNames.Length; if (!isGUIContentSet) { colliderTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { colliderTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((ColliderType)extIdx), }; } isGUIContentSet = true; } colliderTypeProperty.enumValueIndex = EditorGUI.Popup(position, colliderTypeLabel, colliderTypeProperty.enumValueIndex, colliderTypeContent); EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); var scalingType = property.FindPropertyRelative("scalingType"); var displayNames = scalingType.enumDisplayNames; int count = scalingType.enumDisplayNames.Length; if (!isGUIContentSet) { scalingTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { scalingTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((MapScalingType)extIdx), }; } isGUIContentSet = true; } // Draw label. var scalingTypePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = "Scale of map in game units.", }); scalingType.enumValueIndex = EditorGUI.Popup(scalingTypePosition, scalingType.enumValueIndex, scalingTypeContent); if ((MapScalingType)scalingType.enumValueIndex == MapScalingType.Custom) { position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("unityTileSize")); } EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var placementType = property.FindPropertyRelative("placementType"); var snapMapToTerrain = property.FindPropertyRelative("snapMapToZero"); var displayNames = placementType.enumDisplayNames; int count = placementType.enumDisplayNames.Length; if (!isGUIContentSet) { placementTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { placementTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((MapPlacementType)extIdx), }; } isGUIContentSet = true; } placementType.enumValueIndex = EditorGUILayout.Popup(new GUIContent { text = label.text, tooltip = "Placement of Map root.", }, placementType.enumValueIndex, placementTypeContent); EditorGUILayout.PropertyField(snapMapToTerrain, new GUIContent { text = snapMapToTerrain.displayName, tooltip = "If checked, map's root will be snapped to zero. " }); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, null, property); // Draw label. var primitiveType = property.FindPropertyRelative("geometryType"); var primitiveTypeLabel = new GUIContent { text = "Primitive Type", tooltip = "Primitive geometry type of the visualizer, allowed primitives - point, line, polygon." }; var displayNames = primitiveType.enumDisplayNames; int count = primitiveType.enumDisplayNames.Length; if (!_isGUIContentSet) { _primitiveTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { _primitiveTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((VectorPrimitiveType)extIdx), }; } _isGUIContentSet = true; } primitiveType.enumValueIndex = EditorGUILayout.Popup(primitiveTypeLabel, primitiveType.enumValueIndex, _primitiveTypeContent); var serializedMapObject = property.serializedObject; AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject; tileJsonData = mapObject.VectorData.LayerProperty.tileJsonData; var layerDisplayNames = tileJsonData.LayerDisplayNames; DrawLayerName(property, position, layerDisplayNames); var snapToTerrainProperty = property.FindPropertyRelative("snapToTerrain"); var groupFeaturesProperty = property.FindPropertyRelative("groupFeatures"); snapToTerrainProperty.boolValue = EditorGUILayout.Toggle(snapToTerrainProperty.displayName, snapToTerrainProperty.boolValue); groupFeaturesProperty.boolValue = EditorGUILayout.Toggle(groupFeaturesProperty.displayName, groupFeaturesProperty.boolValue); if ((VectorPrimitiveType)primitiveType.enumValueIndex == VectorPrimitiveType.Line) { EditorGUILayout.PropertyField(property.FindPropertyRelative("lineWidth")); } EditorGUI.EndProperty(); }
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(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); var placementType = property.FindPropertyRelative("placementType"); var snapMapToTerrain = property.FindPropertyRelative("snapMapToZero"); EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), placementType, new GUIContent { text = placementType.displayName, tooltip = EnumExtensions.Description((MapPlacementType)placementType.enumValueIndex) }); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), snapMapToTerrain, new GUIContent { text = snapMapToTerrain.displayName, tooltip = "If checked, map's root will be snapped to zero. " }); EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, null, property); var primitiveType = property.FindPropertyRelative("geometryType"); var primitiveTypeLabel = new GUIContent { text = "Primitive Type", tooltip = "Primitive geometry type of the visualizer, allowed primitives - point, line, polygon." }; var displayNames = primitiveType.enumDisplayNames; int count = primitiveType.enumDisplayNames.Length; if (!_isGUIContentSet) { _primitiveTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { _primitiveTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((VectorPrimitiveType)extIdx), }; } _isGUIContentSet = true; } EditorGUI.BeginChangeCheck(); primitiveType.enumValueIndex = EditorGUILayout.Popup(primitiveTypeLabel, primitiveType.enumValueIndex, _primitiveTypeContent); if (EditorGUI.EndChangeCheck()) { EditorHelper.CheckForModifiedProperty(property); } // // if ((VectorPrimitiveType)primitiveType.enumValueIndex == VectorPrimitiveType.Line) // { // EditorGUI.BeginChangeCheck(); // EditorGUILayout.PropertyField(property.FindPropertyRelative("lineWidth")); // if (EditorGUI.EndChangeCheck()) // { // EditorHelper.CheckForModifiedProperty(property); // } // } EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); var scalingType = property.FindPropertyRelative("scalingType"); EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), scalingType, new GUIContent { text = scalingType.displayName, tooltip = EnumExtensions.Description((MapScalingType)scalingType.enumValueIndex) }); if ((MapScalingType)scalingType.enumValueIndex == MapScalingType.Custom) { position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("unityTileSize")); } EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); var placementType = property.FindPropertyRelative("placementType"); var snapMapToTerrain = property.FindPropertyRelative("snapMapToZero"); var displayNames = placementType.enumDisplayNames; int count = placementType.enumDisplayNames.Length; if (!isGUIContentSet) { placementTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { placementTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((MapPlacementType)extIdx), }; } isGUIContentSet = true; } // Draw label. var placementTypePosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = "Placement of Map root.", }); placementType.enumValueIndex = EditorGUI.Popup(placementTypePosition, placementType.enumValueIndex, placementTypeContent); //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), placementType, new GUIContent { text = placementType.displayName, tooltip = EnumExtensions.Description((MapPlacementType)placementType.enumValueIndex) }); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), snapMapToTerrain, new GUIContent { text = snapMapToTerrain.displayName, tooltip = "If checked, map's root will be snapped to zero. " }); EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); var extrusionTypeProperty = property.FindPropertyRelative("extrusionType"); var displayNames = extrusionTypeProperty.enumDisplayNames; int count = extrusionTypeProperty.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((ExtrusionType)extIdx), }; } isGUIContentSet = true; } var typePosition = EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width, lineHeight), GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = "Extrusion Type", tooltip = "Type of geometry extrusion" }); EditorGUI.indentLevel--; extrusionTypeProperty.enumValueIndex = EditorGUI.Popup(typePosition, extrusionTypeProperty.enumValueIndex, sourceTypeContent); EditorGUI.indentLevel++; var sourceTypeValue = (Unity.Map.ExtrusionType)extrusionTypeProperty.enumValueIndex; var minHeightProperty = property.FindPropertyRelative("minimumHeight"); var maxHeightProperty = property.FindPropertyRelative("maximumHeight"); var extrusionGeometryType = property.FindPropertyRelative("extrusionGeometryType"); var extrusionGeometryGUI = new GUIContent { text = "Extrusion Geometry Type", tooltip = EnumExtensions.Description((Unity.Map.ExtrusionGeometryType)extrusionGeometryType.enumValueIndex) }; EditorGUI.indentLevel++; switch (sourceTypeValue) { case Unity.Map.ExtrusionType.None: break; case Unity.Map.ExtrusionType.PropertyHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.MinHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.MaxHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); break; case Unity.Map.ExtrusionType.RangeHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("propertyName")); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), minHeightProperty); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), maxHeightProperty); if (minHeightProperty.floatValue > maxHeightProperty.floatValue) { //position.y += lineHeight; EditorGUILayout.HelpBox("Maximum Height less than Minimum Height!", MessageType.Error); } break; case Unity.Map.ExtrusionType.AbsoluteHeight: position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), extrusionGeometryType, extrusionGeometryGUI); position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), maxHeightProperty, new GUIContent { text = "Height" }); break; default: break; } position.y += lineHeight; EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, lineHeight), property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); EditorGUI.indentLevel--; EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { LoadDefaultStyleIcons(); EditorGUI.BeginProperty(position, label, property); //position.y += lineHeight; var styleTypeLabel = new GUIContent { text = "Texturing Style", tooltip = "Texturing style for feature; choose from sample style or create your own by choosing Custom. " }; var styleType = property.FindPropertyRelative("style"); GUIContent[] styleTypeGuiContent = new GUIContent[styleType.enumDisplayNames.Length]; for (int i = 0; i < styleType.enumDisplayNames.Length; i++) { styleTypeGuiContent[i] = new GUIContent { text = styleType.enumDisplayNames[i] }; } styleType.enumValueIndex = EditorGUILayout.Popup(styleTypeLabel, styleType.enumValueIndex, styleTypeGuiContent); EditorGUI.indentLevel++; if ((StyleTypes)styleType.enumValueIndex != StyleTypes.Custom) { GUILayout.BeginHorizontal(); Texture2D thumbnailTexture = (Texture2D)_styleIconBundles[(StyleTypes)styleType.enumValueIndex].texture; string descriptionLabel = EnumExtensions.Description((StyleTypes)styleType.enumValueIndex); EditorGUILayout.LabelField(new GUIContent(" ", thumbnailTexture), Constants.GUI.Styles.EDITOR_TEXTURE_THUMBNAIL_STYLE, GUILayout.Height(60), GUILayout.Width(EditorGUIUtility.labelWidth - 60)); EditorGUILayout.TextArea(descriptionLabel, (GUIStyle)"wordWrappedLabel"); GUILayout.EndHorizontal(); } else { var texturingType = property.FindPropertyRelative("texturingType"); int valIndex = texturingType.enumValueIndex == 0 ? 0 : texturingType.enumValueIndex + 1; var texturingTypeGUI = new GUIContent { text = "Texturing Type", tooltip = EnumExtensions.Description((UvMapType)valIndex) }; EditorGUILayout.PropertyField(texturingType, texturingTypeGUI); var matList = property.FindPropertyRelative("materials"); if (matList.arraySize == 0) { matList.arraySize = 2; } GUILayout.Space(-lineHeight); var roofMat = matList.GetArrayElementAtIndex(0); EditorGUILayout.PropertyField(roofMat, new GUIContent { text = "Top Material", tooltip = "Unity material to use for extruded top/roof mesh. " }); GUILayout.Space(-lineHeight); var wallMat = matList.GetArrayElementAtIndex(1); EditorGUILayout.PropertyField(wallMat, new GUIContent { text = "Side Material", tooltip = "Unity material to use for extruded side/wall mesh. " }); if ((UvMapType)texturingType.enumValueIndex + 1 == UvMapType.Atlas) { var atlasInfo = property.FindPropertyRelative("atlasInfo"); EditorGUILayout.ObjectField(atlasInfo, new GUIContent { text = "Altas Info", tooltip = "Atlas information scriptable object, this defines how the texture roof and wall texture atlases will be used. " }); } if ((UvMapType)texturingType.enumValueIndex + 1 == UvMapType.AtlasWithColorPalette) { var atlasInfo = property.FindPropertyRelative("atlasInfo"); EditorGUILayout.ObjectField(atlasInfo, new GUIContent { text = "Altas Info", tooltip = "Atlas information scriptable object, this defines how the texture roof and wall texture atlases will be used. " }); var colorPalette = property.FindPropertyRelative("colorPalette"); EditorGUILayout.ObjectField(colorPalette, new GUIContent { text = "Color Palette", tooltip = "Color palette scriptable object, allows texture features to be procedurally colored at runtime. Requires materials that use the MapboxPerRenderer shader. " }); EditorGUILayout.LabelField(new GUIContent { text = "Note: Atlas With Color Palette requires materials that use the MapboxPerRenderer shader." }, Constants.GUI.Styles.EDITOR_NOTE_STYLE); } } EditorGUI.indentLevel--; EditorGUI.EndProperty(); }
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 = (VectorSourceType)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 = (VectorSourceType)sourceTypeProperty.enumValueIndex; position.y += lineHeight; var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions"); var isActiveProperty = sourceOptionsProperty.FindPropertyRelative("isActive"); switch (sourceTypeValue) { case VectorSourceType.MapboxStreets: case VectorSourceType.MapboxStreetsWithBuildingIds: var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue); var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource"); var layerSourceId = layerSourceProperty.FindPropertyRelative("Id"); layerSourceId.stringValue = sourcePropertyValue.Id; GUI.enabled = false; EditorGUILayout.PropertyField(sourceOptionsProperty, new GUIContent("Source Option")); GUI.enabled = true; isActiveProperty.boolValue = true; break; case VectorSourceType.Custom: EditorGUILayout.PropertyField(sourceOptionsProperty, new GUIContent("Source Option")); 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", tooltip = "Visualizers for vector features contained in a layer. " }); var subLayerArray = property.FindPropertyRelative("vectorSubLayers"); 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(); GUILayout.Space(EditorGUIUtility.singleLineHeight); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Add Visualizer"), (GUIStyle)"minibuttonleft")) { subLayerArray.arraySize++; //subLayerArray.InsertArrayElementAtIndex(subLayerArray.arraySize); var subLayer = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1); var subLayerName = subLayer.FindPropertyRelative("coreOptions.sublayerName"); Debug.Log("Active status -> " + subLayer.FindPropertyRelative("coreOptions.isActive").boolValue.ToString()); subLayerName.stringValue = "Untitled"; // Set defaults here beacuse SerializedProperty copies the previous element. var subLayerCoreOptions = subLayer.FindPropertyRelative("coreOptions"); subLayerCoreOptions.FindPropertyRelative("isActive").boolValue = true; subLayerCoreOptions.FindPropertyRelative("layerName").stringValue = "building"; subLayerCoreOptions.FindPropertyRelative("geometryType").enumValueIndex = (int)VectorPrimitiveType.Polygon; subLayerCoreOptions.FindPropertyRelative("snapToTerrain").boolValue = true; subLayerCoreOptions.FindPropertyRelative("groupFeatures").boolValue = false; subLayerCoreOptions.FindPropertyRelative("lineWidth").floatValue = 1.0f; var subLayerExtrusionOptions = subLayer.FindPropertyRelative("extrusionOptions"); subLayerExtrusionOptions.FindPropertyRelative("propertyName").stringValue = "height"; } if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright")) { foreach (var index in selectedLayers.OrderByDescending(i => i)) { subLayerArray.DeleteArrayElementAtIndex(index); } selectedLayers = new int[0]; layerTreeView.SetSelection(selectedLayers); } GUILayout.EndHorizontal(); GUILayout.Space(EditorGUIUtility.singleLineHeight); if (selectedLayers.Count == 1) { var index = selectedLayers[0]; var layerProperty = subLayerArray.GetArrayElementAtIndex(index); layerProperty.isExpanded = true; DrawLayerVisualizerProperties(layerProperty); } else { GUILayout.Label("Select a visualizer to see properties"); } } EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var extrusionTypeProperty = property.FindPropertyRelative("extrusionType"); var displayNames = extrusionTypeProperty.enumDisplayNames; int count = extrusionTypeProperty.enumDisplayNames.Length; if (!isGUIContentSet) { extrusionTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { extrusionTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((ExtrusionType)extIdx), }; } isGUIContentSet = true; } var extrusionTypeLabel = new GUIContent { text = "Extrusion Type", tooltip = "Type of geometry extrusion" }; extrusionTypeProperty.enumValueIndex = EditorGUILayout.Popup(extrusionTypeLabel, extrusionTypeProperty.enumValueIndex, extrusionTypeContent); var sourceTypeValue = (Unity.Map.ExtrusionType)extrusionTypeProperty.enumValueIndex; var minHeightProperty = property.FindPropertyRelative("minimumHeight"); var maxHeightProperty = property.FindPropertyRelative("maximumHeight"); var extrusionGeometryType = property.FindPropertyRelative("extrusionGeometryType"); var extrusionGeometryGUI = new GUIContent { text = "Extrusion Geometry Type", tooltip = EnumExtensions.Description((Unity.Map.ExtrusionGeometryType)extrusionGeometryType.enumValueIndex) }; EditorGUI.indentLevel++; switch (sourceTypeValue) { case Unity.Map.ExtrusionType.None: break; case Unity.Map.ExtrusionType.PropertyHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); DrawPropertyDropDown(property, position); break; case Unity.Map.ExtrusionType.MinHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); DrawPropertyDropDown(property, position); break; case Unity.Map.ExtrusionType.MaxHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); DrawPropertyDropDown(property, position); break; case Unity.Map.ExtrusionType.RangeHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); DrawPropertyDropDown(property, position); EditorGUILayout.PropertyField(minHeightProperty); EditorGUILayout.PropertyField(maxHeightProperty); if (minHeightProperty.floatValue > maxHeightProperty.floatValue) { EditorGUILayout.HelpBox("Maximum Height less than Minimum Height!", MessageType.Error); } break; case Unity.Map.ExtrusionType.AbsoluteHeight: EditorGUILayout.PropertyField(extrusionGeometryType, extrusionGeometryGUI); EditorGUILayout.PropertyField(maxHeightProperty, new GUIContent { text = "Height" }); break; default: break; } EditorGUILayout.PropertyField(property.FindPropertyRelative("extrusionScaleFactor"), new GUIContent { text = "Scale Factor" }); EditorGUI.indentLevel--; }
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 = (ElevationSourceType)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 = (ElevationSourceType)sourceTypeProperty.enumValueIndex; position.y += lineHeight; switch (sourceTypeValue) { case ElevationSourceType.MapboxTerrain: var sourcePropertyValue = MapboxDefaultElevation.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, new GUIContent("Source Option")); GUI.enabled = true; break; case ElevationSourceType.Custom: EditorGUI.PropertyField(position, property.FindPropertyRelative("sourceOptions"), true); break; default: break; } //EditorGUI.PropertyField(position, property.FindPropertyRelative("sourceOptions"), true); if (sourceTypeValue != ElevationSourceType.None) { position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sourceOptions")); } if (sourceTypeValue == ElevationSourceType.None) { GUI.enabled = false; } var elevationLayerType = property.FindPropertyRelative("elevationLayerType"); EditorGUI.PropertyField(position, elevationLayerType, new GUIContent { text = elevationLayerType.displayName, tooltip = EnumExtensions.Description((ElevationLayerType)elevationLayerType.enumValueIndex) }); position.y += lineHeight; if (sourceTypeValue == ElevationSourceType.None) { GUI.enabled = true; } EditorGUI.PropertyField(position, property.FindPropertyRelative("requiredOptions"), true); position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("requiredOptions")); showPosition = EditorGUI.Foldout(position, showPosition, "Others"); if (showPosition) { position.y += lineHeight; EditorGUI.PropertyField(position, property.FindPropertyRelative("modificationOptions"), true); position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("modificationOptions")); EditorGUI.PropertyField(position, property.FindPropertyRelative("sideWallOptions"), true); position.y += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("sideWallOptions")); EditorGUI.PropertyField(position, property.FindPropertyRelative("unityLayerOptions"), true); } EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var kindProperty = property.FindPropertyRelative(extTypePropertyName); var displayNames = kindProperty.enumDisplayNames; int count = kindProperty.enumDisplayNames.Length; if (!isGUIContentSet) { extentTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { extentTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((MapExtentType)extIdx), }; } isGUIContentSet = true; } // Draw label. var extentTypeLabel = new GUIContent { text = label.text, tooltip = "Options to determine the geographic extent of the world for which the map tiles will be requested.", }; EditorGUI.BeginChangeCheck(); kindProperty.enumValueIndex = EditorGUILayout.Popup(extentTypeLabel, kindProperty.enumValueIndex, extentTypeContent, GUILayout.Height(_lineHeight)); var kind = (MapExtentType)kindProperty.enumValueIndex; if (EditorGUI.EndChangeCheck()) { EditorHelper.CheckForModifiedProperty(property); } EditorGUI.indentLevel++; GUILayout.Space(-_lineHeight); SerializedProperty defaultExtentsProp = property.FindPropertyRelative("defaultExtents"); EditorGUI.BeginChangeCheck(); switch (kind) { case MapExtentType.CameraBounds: GUILayout.Space(_lineHeight); EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("cameraBoundsOptions"), new GUIContent { text = "CameraOptions-" }); break; case MapExtentType.RangeAroundCenter: EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("rangeAroundCenterOptions"), new GUIContent { text = "RangeAroundCenter" }); break; case MapExtentType.RangeAroundTransform: GUILayout.Space(_lineHeight); EditorGUILayout.PropertyField(defaultExtentsProp.FindPropertyRelative("rangeAroundTransformOptions"), new GUIContent { text = "RangeAroundTransform" }); break; default: break; } if (EditorGUI.EndChangeCheck()) { EditorHelper.CheckForModifiedProperty(defaultExtentsProp); } EditorGUI.indentLevel--; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); position.height = lineHeight; var kindProperty = property.FindPropertyRelative(extTypePropertyName); var displayNames = kindProperty.enumDisplayNames; int count = kindProperty.enumDisplayNames.Length; GUIContent[] extentTypeContent = new GUIContent[count]; for (int extIdx = 0; extIdx < count; extIdx++) { extentTypeContent[extIdx] = new GUIContent { text = displayNames[extIdx], tooltip = EnumExtensions.Description((MapExtentType)extIdx), }; } // Draw label. var kindPosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent { text = label.text, tooltip = EnumExtensions.Description((MapExtentType)kindProperty.enumValueIndex), }); kindProperty.enumValueIndex = EditorGUI.Popup(kindPosition, kindProperty.enumValueIndex, extentTypeContent); var kind = (MapExtentType)kindProperty.enumValueIndex; EditorGUI.indentLevel++; var rect = new Rect(position.x, position.y + lineHeight, position.width, lineHeight); switch (kind) { case MapExtentType.CameraBounds: EditorGUI.PropertyField(rect, property.FindPropertyRelative("cameraBoundsOptions"), new GUIContent { text = "CameraOptions-" }); break; case MapExtentType.RangeAroundCenter: EditorGUI.PropertyField(rect, property.FindPropertyRelative("rangeAroundCenterOptions"), new GUIContent { text = "RangeAroundCenter" }); break; case MapExtentType.RangeAroundTransform: EditorGUI.PropertyField(rect, property.FindPropertyRelative("rangeAroundTransformOptions"), new GUIContent { text = "RangeAroundTransform" }); break; default: break; } EditorGUI.indentLevel--; EditorGUI.EndProperty(); }
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) { objectId = property.serializedObject.targetObject.GetInstanceID().ToString(); showTexturing = EditorGUILayout.Foldout(showTexturing, new GUIContent { text = "Texturing", tooltip = "Material options to texture the generated building geometry" }); if (showTexturing) { LoadDefaultStyleIcons(); EditorGUI.BeginProperty(position, label, property); var styleTypeLabel = new GUIContent { text = "Style Type", tooltip = "Texturing style for feature; choose from sample style or create your own by choosing Custom. " }; var styleType = property.FindPropertyRelative("style"); GUIContent[] styleTypeGuiContent = new GUIContent[styleType.enumDisplayNames.Length]; for (int i = 0; i < styleType.enumDisplayNames.Length; i++) { styleTypeGuiContent[i] = new GUIContent { text = styleType.enumDisplayNames[i] }; } styleType.enumValueIndex = EditorGUILayout.Popup(styleTypeLabel, styleType.enumValueIndex, styleTypeGuiContent); EditorGUI.indentLevel++; if ((StyleTypes)styleType.enumValueIndex != StyleTypes.Custom) { GUILayout.BeginHorizontal(); var style = (StyleTypes)styleType.enumValueIndex; Texture2D thumbnailTexture = (Texture2D)_styleIconBundles[style].texture; if ((StyleTypes)styleType.enumValueIndex == StyleTypes.Simple) { var samplePaletteType = property.FindPropertyRelative("samplePalettes"); var palette = (SamplePalettes)samplePaletteType.enumValueIndex; thumbnailTexture = (Texture2D)_paletteIconBundles[palette].texture; } string descriptionLabel = EnumExtensions.Description(style); EditorGUILayout.LabelField(new GUIContent(" ", thumbnailTexture), Constants.GUI.Styles.EDITOR_TEXTURE_THUMBNAIL_STYLE, GUILayout.Height(60), GUILayout.Width(EditorGUIUtility.labelWidth - 60)); EditorGUILayout.TextArea(descriptionLabel, (GUIStyle)"wordWrappedLabel"); GUILayout.EndHorizontal(); switch ((StyleTypes)styleType.enumValueIndex) { case StyleTypes.Simple: var samplePaletteType = property.FindPropertyRelative("samplePalettes"); var samplePaletteTypeLabel = new GUIContent { text = "Palette Type", tooltip = "Palette type for procedural colorization; choose from sample palettes or create your own by choosing Custom. " }; GUIContent[] samplePaletteTypeGuiContent = new GUIContent[samplePaletteType.enumDisplayNames.Length]; for (int i = 0; i < samplePaletteType.enumDisplayNames.Length; i++) { samplePaletteTypeGuiContent[i] = new GUIContent { text = samplePaletteType.enumDisplayNames[i] }; } samplePaletteType.enumValueIndex = EditorGUILayout.Popup(samplePaletteTypeLabel, samplePaletteType.enumValueIndex, samplePaletteTypeGuiContent); break; case StyleTypes.Light: property.FindPropertyRelative("lightStyleOpacity").floatValue = EditorGUILayout.Slider("Opacity", property.FindPropertyRelative("lightStyleOpacity").floatValue, 0.0f, 1.0f); break; case StyleTypes.Dark: property.FindPropertyRelative("darkStyleOpacity").floatValue = EditorGUILayout.Slider("Opacity", property.FindPropertyRelative("darkStyleOpacity").floatValue, 0.0f, 1.0f); break; case StyleTypes.Color: property.FindPropertyRelative("colorStyleColor").colorValue = EditorGUILayout.ColorField("Color", property.FindPropertyRelative("colorStyleColor").colorValue); break; default: break; } } else { var texturingType = property.FindPropertyRelative("texturingType"); int valIndex = texturingType.enumValueIndex == 0 ? 0 : texturingType.enumValueIndex + 1; var texturingTypeGUI = new GUIContent { text = "Texturing Type", tooltip = EnumExtensions.Description((UvMapType)valIndex) }; EditorGUILayout.PropertyField(texturingType, texturingTypeGUI); var matList = property.FindPropertyRelative("materials"); if (matList.arraySize == 0) { matList.arraySize = 2; } GUILayout.Space(-lineHeight); var roofMat = matList.GetArrayElementAtIndex(0); EditorGUILayout.PropertyField(roofMat, new GUIContent { text = "Top Material", tooltip = "Unity material to use for extruded top/roof mesh. " }); GUILayout.Space(-lineHeight); var wallMat = matList.GetArrayElementAtIndex(1); EditorGUILayout.PropertyField(wallMat, new GUIContent { text = "Side Material", tooltip = "Unity material to use for extruded side/wall mesh. " }); if ((UvMapType)texturingType.enumValueIndex + 1 == UvMapType.Atlas) { var atlasInfo = property.FindPropertyRelative("atlasInfo"); EditorGUILayout.ObjectField(atlasInfo, new GUIContent { text = "Altas Info", tooltip = "Atlas information scriptable object, this defines how the texture roof and wall texture atlases will be used. " }); } if ((UvMapType)texturingType.enumValueIndex + 1 == UvMapType.AtlasWithColorPalette) { var atlasInfo = property.FindPropertyRelative("atlasInfo"); EditorGUILayout.ObjectField(atlasInfo, new GUIContent { text = "Altas Info", tooltip = "Atlas information scriptable object, this defines how the texture roof and wall texture atlases will be used. " }); var colorPalette = property.FindPropertyRelative("colorPalette"); EditorGUILayout.ObjectField(colorPalette, new GUIContent { text = "Color Palette", tooltip = "Color palette scriptable object, allows texture features to be procedurally colored at runtime. Requires materials that use the MapboxPerRenderer shader. " }); EditorGUILayout.LabelField(new GUIContent { text = "Note: Atlas With Color Palette requires materials that use the MapboxPerRenderer shader." }, Constants.GUI.Styles.EDITOR_NOTE_STYLE); } } EditorGUI.indentLevel--; EditorGUI.EndProperty(); } }