Tooltip when mousing over a game object..whats wrong in this script

Hii,

i have a collider on my object and IsTrigger is set, but when i mouse over i dont see anything…whats wrong ?

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);
    }
}

ref post: Tooltip when mousing over a game object? - Questions & Answers - Unity Discussions

Put a:

Debug.Log("Mouse Entered!");

Debug.Log("Mouse Exited!");

…in your Enter and Exit functions respectively - that’ll narrow the issue down.

-JFFM

There’s nothing wrong with your script. I tried it on a simple sphere object, it shows the tooltip text right below the mouse cursor.

I will say the problem might be your layers http://unity3d.com/support/documentation/Components/Layers.html.

Perhaps ur layer of ur object is accidentally set to ignore raycast or whatever. Because currently i also tried out ur script and it is working fine and when i try to switch it to ignore raycast layer, it doesn’t show the words. So i guessing u might have changed the layers. Hope that helps.

ok so it works now, can i add a nice background to text as it is floating in air…what to update in script

Not very about that, but i think u can add another gui.label that hold a texture in addition to ur current gui.label.

i just added a line in code, mouse over is working, i want to open a pop-up window on click , so i added a line in a function

but left click doesnt work, any suggesstions ??

i also tried this way -

Ur function update should be function Update().