- Home /
How do I detect a mouse hover?
I am trying to make a script that would do something when I hover over a 3D Text object. This is what I think is correct...
#Pragma Strict
function OnMouseOver()
{
//Do something
}
function LeaveMouseOver()
{
/Do something else
}
Answer by robertbu · Jul 17, 2014 at 05:00 PM
There is no OnMouseLeave(). It is OnMouseExit(). And what you will will depend on what you are doing during the hover. Typically you would either use an OnMouseEnter() and OnMouseExit() as a pair, or OnMouseOver(). Note that 3D Text does not come with a collider. Typically folks who want to do some sort of collision or raycasting against a 3D Text object (which is what is happening under the hood when you use the OnMouse* callbacks) put a BoxCollider on the 3D Text.
Your answer
![](https://koobas.hobune.stream/wayback/20220613154330im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make a Hover event on GUI.Button 6 Answers
make an object glow when mouse over 3 Answers
Detect Mouse Movement 1 Answer
Mouse Click not detected 1 Answer
i was wondering about gui hover... 3 Answers