public static float HeightWithLabel(Metadata metadata, float width, float height, GUIContent label = null, GUIStyle labelStyle = null) { label = ProcessLabel(metadata, label); if (label == GUIContent.none) { return(height); } var labelWidth = LabelWidth(metadata, width); labelStyle = ProcessLabelStyle(metadata, labelStyle); var wide = metadata.HasAttribute <InspectorWideAttribute>(); var labelHeight = labelStyle.CalcHeight(label, labelWidth); if (expandTooltip.value || metadata.HasAttribute <InspectorExpandTooltipAttribute>()) { var tooltipHeight = StringUtility.IsNullOrWhiteSpace(label.tooltip) ? 0 : LudiqStyles.expandedTooltip.CalcHeight(new GUIContent(label.tooltip), labelWidth); if (wide) { height += labelHeight + tooltipHeight; } else { height = Mathf.Max(height, labelHeight + tooltipHeight); } } else { if (wide) { height += labelHeight; } else { height = Mathf.Max(height, labelHeight); } } return(height); }
public static Rect PrefixLabel(Metadata metadata, Rect position, GUIContent label = null, GUIStyle style = null) { label = ProcessLabel(metadata, label); if (label == GUIContent.none) { return(position); } var width = LabelWidth(metadata, position.width); style = ProcessLabelStyle(metadata, style); var wide = metadata.HasAttribute <InspectorWideAttribute>(); var y = position.y; var labelPosition = new Rect ( position.x, position.y, width, style.CalcHeight(label, width) ); y = labelPosition.yMax + 2; var expandTooltip = Inspector.expandTooltip || metadata.HasAttribute <InspectorExpandTooltipAttribute>(); EditorGUI.LabelField(labelPosition, expandTooltip ? new GUIContent(label.text, label.image) : label, style); if (LudiqCore.Configuration.developerMode && LudiqCore.Configuration.debugInspectorGUI && e.type == EventType.Repaint) { labelDebugBox.Draw(labelPosition, false, false, false, false); } if (expandTooltip) { var tooltip = new GUIContent(label.tooltip); var tooltipPosition = new Rect ( position.x, y - 2, width, LudiqStyles.expandedTooltip.CalcHeight(tooltip, width) ); EditorGUI.LabelField(tooltipPosition, tooltip, LudiqStyles.expandedTooltip); if (LudiqCore.Configuration.developerMode && LudiqCore.Configuration.debugInspectorGUI && e.type == EventType.Repaint) { labelDebugBox.Draw(tooltipPosition, false, false, false, false); } y = tooltipPosition.yMax - 4; } Rect remainingPosition; if (wide) { remainingPosition = new Rect ( position.x, y, position.width, position.height - labelPosition.height ); } else { remainingPosition = new Rect ( labelPosition.xMax, position.y, position.width - labelPosition.width, position.height ); } return(remainingPosition); }