В GUIStyle подсказки нужно включить Word Wrap, и Stretch Height (Stretch Width выключить), Border по 5, Padding по 2, Alignment - MiddleCenter.
- Код: Выделить всё
var styleTooltip : GUIStyle;
private var tooltipDelay : float = 0.5;
private var tooltipDelayer : float;
function Tooltip () {
var tooltip : String = GUI.tooltip;
//Задержка перед отображением
if(tooltip == "") {
if(tooltipDelayer > 0) tooltipDelayer -= Time.deltaTime/2;
return;
}
else if(tooltipDelayer < tooltipDelay + 0.1) {
tooltipDelayer += Time.deltaTime;
}
if(tooltipDelayer < tooltipDelay) return;
//Вычислить позицию
var tooltipX : float = Input.mousePosition.x + 10;
var tooltipY : float = Screen.height - Input.mousePosition.y;
var tooltipWidth : float = 150 + tooltip.length;
var tooltipHeight : float = 34 + (5 * (tooltip.length/20));
if(tooltipX > Screen.width - tooltipWidth) tooltipX = Input.mousePosition.x - tooltipWidth;
if(Input.mousePosition.y < tooltipHeight) tooltipY -= tooltipHeight;
//Отобразить подсказку
GUI.Box( Rect(tooltipX, tooltipY, tooltipWidth, tooltipHeight), tooltip, GUIStyle(styleTooltip) );
}