x


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.

more ▼

asked Oct 03 '11 at 12:39 PM

meena gravatar image

meena
16 8 9 10

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3680
x75
x53
x49
x2

asked: Oct 03 '11 at 12:39 PM

Seen: 706 times

Last Updated: Oct 03 '11 at 12:39 PM