- Home /
When the mouse (cursor) scrolls over an object, GUIText will appear on screen as long as it hovers over that object?
I'm trying to make a door that sais 'You need a key to open this door!' whenever you scroll over it. I just don't know how to do it, can anyone help?
Are you wanting a free moving mouse cursor, or do you want it to read out this text when your player looks at the door? Do you use JS or C#?
Whenever the player looks at the door, and I use JS.
Answer by pad406 · Dec 28, 2012 at 02:42 PM
You'll need to have a collider attached to the door object. Then attach a script to it which uses 2 functions:
void OnMouseEnter()
void OnMouseExit()
in OnMouseEnter instantiate your text object if it doesn't exist and in OnMouseExit destroy it if it does. Or you can simply use a GUI.Label drawn at the correct co-ordinates (in OnGUI) based on a boolean set in the above functions.
Your answer

Follow this Question
Related Questions
JavaScript: _player.cursor(280) 1 Answer
Changing cursor over multiple objects 0 Answers
Help in GUI issue - Can't lose focus of a dropdown list when mouse clicks somewhere else? 0 Answers
How do I make my mouse go back to default after clicking empty space? 0 Answers
unity2D: make object face mouse 2 Answers