Skip to content

Commit 24e0b59

Browse files
authored
Fix tooltip not fitting in narrow windows (#74)
1 parent 75f07f5 commit 24e0b59

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎RuntimeUnityEditor/WindowBase.cs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,20 @@ private void DrawTooltip(Rect area)
160160
}
161161

162162
_tooltipContent.text = GUI.tooltip;
163-
var height = _tooltipStyle.CalcHeight(_tooltipContent, TooltipWidth) + 10;
163+
var tooltipWidth = Mathf.Min(TooltipWidth, WindowRect.width);
164+
var height = _tooltipStyle.CalcHeight(_tooltipContent, tooltipWidth) + 10;
164165

165166
var currentEvent = Event.current;
166167

167-
var x = currentEvent.mousePosition.x + TooltipWidth > area.width
168-
? area.width - TooltipWidth
168+
var x = currentEvent.mousePosition.x + tooltipWidth > area.width
169+
? area.width - tooltipWidth
169170
: currentEvent.mousePosition.x;
170171

171172
var y = currentEvent.mousePosition.y + 25 + height > area.height
172173
? currentEvent.mousePosition.y - height
173174
: currentEvent.mousePosition.y + 25;
174175

175-
GUI.Box(new Rect(x, y, TooltipWidth, height), GUI.tooltip, _tooltipStyle);
176+
GUI.Box(new Rect(x, y, tooltipWidth, height), GUI.tooltip, _tooltipStyle);
176177
}
177178
}
178179

0 commit comments

Comments
 (0)