public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { TileDataAttribute tileDataAttrib = attribute as TileDataAttribute; return(EditorGUIUtility.singleLineHeight + (tileDataAttrib.displayProperties && property.isExpanded ? Mathf.Max(tileDataAttrib.tileSize, 114f) : tileDataAttrib.tileSize + 4f)); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { TileDataAttribute tileDataAttrib = attribute as TileDataAttribute; if (property.propertyType != SerializedPropertyType.Integer) { Debug.LogError("SortedLayer property should be an integer"); } else { Tileset tileset = null; if (property.serializedObject.targetObject is MonoBehaviour) { STETilemap parentTilemap = (property.serializedObject.targetObject as MonoBehaviour).GetComponentInParent <STETilemap>(); if (parentTilemap) { tileset = parentTilemap.Tileset; } } else if (property.serializedObject.targetObject is TilesetBrush) { tileset = (property.serializedObject.targetObject as TilesetBrush).Tileset; } Rect rIntLabel = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); Rect rContent = new Rect(position.x, position.y + rIntLabel.height + 2f, position.width, position.height - rIntLabel.height); EditorGUI.PropertyField(rIntLabel, property, label); if (tileset) { Rect rVisualTile = EditorGUI.PrefixLabel(rContent, new GUIContent("Preview")); rVisualTile.width = rVisualTile.height = tileDataAttrib.tileSize; TileDataField(rVisualTile, label, property, tileset); if (tileDataAttrib.displayProperties) { Rect rTileProperties = new Rect(rVisualTile.xMax + 4f, rContent.y, rContent.width - rVisualTile.xMax - 4f, EditorGUIUtility.singleLineHeight); property.isExpanded = EditorGUI.Foldout(rTileProperties, property.isExpanded, "Tile Properties"); if (property.isExpanded) { rTileProperties.y += rTileProperties.height + 2f; rTileProperties.height = 90f; property.intValue = (int)TileGridControl.DoTileDataProperties(rTileProperties, (uint)property.intValue, tileset); } } } else { EditorGUI.HelpBox(rContent, "Tileset was not found!", MessageType.Warning); } } }