Tooltip and paraghraphing ?

Hi All I am using this script to create a tooltip on my objects.

var toolTipText = ""; // set this in the Inspector

private var currentToolTipText = "";
private var guiStyleFore : GUIStyle;
private var guiStyleBack : GUIStyle;

function Start()
{
    guiStyleFore = new GUIStyle();
    guiStyleFore.normal.textColor = Color.white;  
    guiStyleFore.alignment = TextAnchor.UpperCenter ;
    guiStyleFore.wordWrap = true;
    guiStyleBack = new GUIStyle();
    guiStyleBack.normal.textColor = Color.black;  
    guiStyleBack.alignment = TextAnchor.UpperCenter ;
    guiStyleBack.wordWrap = true;
}

function OnMouseEnter ()
{

    currentToolTipText = toolTipText;
}

function OnMouseExit ()
{
    currentToolTipText = "";
}

function OnGUI()
{
    if (currentToolTipText != "")
    {
        var x = Event.current.mousePosition.x;
        var y = Event.current.mousePosition.y;
        GUI.Label (Rect (x-149,y+21,300,60), currentToolTipText, guiStyleBack);
        GUI.Label (Rect (x-150,y+20,300,60), currentToolTipText, guiStyleFore);
    }
}

Now this works perfectly fine but how would I go about making it so I can have a paragraph instead of one sentence ?

Eg.

Tower 1

5 coins

Generates 10 output

The GUI system supports most control characters like (new line) (tab). However those escape characters only work when written in code like this:

var myToolTip = "first line

second line

another line seperated with a blank line";

However to be able to input multiline text in the inspector there are two ways:

  • you can insert multiline strings with copy&paste that you have written in an editor (like notepad, MonoDevelop, VisualStudio, …).
  • you can create an custom inspector for your class (script) and provide a TextArea instead of an TextField for the string. It’s a bit more work, but if you have to set many of those tooltips it’s much easier with a custom inspector.