Search Unity

Background to tooltip - how?

Discussion in 'Immediate Mode GUI (IMGUI)' started by monark, Jul 23, 2008.

  1. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    I have a tooltip that i want to be on a semi- transparent background so I've added a 60% black image to the background of my skin for labels. The thing is I need the label to resize to fit the tooltip. Since the tooltip varies in size depending on what it is set to, is there a way to find the size of GUI.tooltip?
     
  2. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Found it...

    var tooltipSize : Vector2 = mySkin.label.CalcSize(GUIContent(GUI.tooltip) );
     
  3. Michele

    Michele

    Joined:
    Apr 28, 2008
    Posts:
    73
    Hi,

    Could explain me how we can use a background with a tooltip?
    At the moment I can only print text in a transparent Label... but the tooltip have to be visible only on mouse over a specific button...



    Code (csharp):
    1.  
    2. GUI.skin = myButton4V;
    3.     buttonVG = GUI.Button (Rect (_pos_x+260,_pos_y+232,100,55), GUIContent("","ToolTip_Text"));
    4.  
    5.     if (buttonVG) {
    6.        
    7.     }
    8.    
    9. //TOOLTIP
    10.  
    11.     GUI.Label(Rect (Event.current.mousePosition.x,Event.current.mousePosition.y,100,55), GUI.tooltip);
    Any suggestions?

    Thanx Bye
     
  4. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Add a GUIstyle to it and set the background in the style to an image.
     
  5. Michele

    Michele

    Joined:
    Apr 28, 2008
    Posts:
    73
    Oh thank you for your quick reply...

    Ok I have just add a GUIStyle on my Label...but I discorver that the Style is always visible and this is obviously... :wink:

    I have to do an "If - condition" on the position of mouse on the window to check if it is over the right button or I'm misunderstanding something?
     
  6. Michele

    Michele

    Joined:
    Apr 28, 2008
    Posts:
    73
    Oh ok...I found the error... The Error was ME!!!
    It was too easy... only a check if the tooltip is null...
    :wink:

    Thanx