- Home /
Question by
meena · Oct 03, 2011 at 12:39 PM ·
guimousepositiononmouseovertooltip
tooltip OnMouseOver - screen or mouse position?
I have several game objects that the user can click on (lmb) to show/hide labels; when enabled, the labels then move around the screen following the go's screen position. However, I'd also like to have a tooltip appear when the mouse is over the g.o.
Based on a couple of different postings here (1,2), I changed my code a bit to the following:
var fmrToggle: boolean = false;
var screenPosition : Vector3;
function OnMouseOver (){
screenPosition = Event.current.mousePosition;
}
function OnMouseDown (){
fmrToggle = !fmrToggle;
}
function OnGUI (){
if (fmrToggle) {
GUI.Label(Rect(screenPosition.x, screenPosition.y, 50, 20),"Femur", GUI.tooltip);
}
}
function Update (){
screenPosition = Camera.main.WorldToScreenPoint(transform.position);
screenPosition.y = Screen.height - screenPosition.y;
}
but am still getting no tooltip when the mouse is over the gameobject. Any ideas would be great - thank you.
Comment
Your answer
Follow this Question
Related Questions
Create GUI at mousePosition. 1 Answer
How can I create complex tooltips 2 Answers
tooltip to show from array C# 1 Answer
Why can't I get my tooltip to show only when there is a tooltip set? 2 Answers