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
JFFM
June 23, 2011, 6:27am
2
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.
zine92
June 23, 2011, 7:38am
4
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
zine92
June 23, 2011, 8:34am
6
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
function OnMouseEnter ()
{
currentToolTipText = toolTipText;
//popupminmax.minM =! false;
if(Input.GetMouseButton(0))
{
clickLeft = 1;
Debug.Log(clickLeft + “Pressed right click.”);
}
}
but left click doesnt work, any suggesstions ??
i also tried this way -
function OnMouseEnter ()
{
mouseIsOnIT = 1;
currentToolTipText = toolTipText;
//popupminmax.minM =! false;
}
function update ()
{
if (mouseIsOnIT == 1 Input.GetMouseButton(0))
{
clickLeft = 1;
Debug.Log(clickLeft + “Pressed left click.”);
}
}
zine92
June 23, 2011, 1:04pm
8
Ur function update should be function Update().