Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Yield WaitforSeconds in the GUI

Discussion in 'Immediate Mode GUI (IMGUI)' started by Michele, Dec 19, 2008.

  1. Michele

    Michele

    Joined:
    Apr 28, 2008
    Posts:
    73
    Hi,

    I have implemented a tooltip on my customized buttons. Now my target is to visualize this tooltip after a few seconds that the mouse is on the button...

    I have read some post about the "WaitForSeconds" function (such as: http://forum.unity3d.com/viewtopic.php?t=13692&highlight=yeild+yield), but I think I'm a little bit confused...:roll:

    Code (csharp):
    1.  
    2. private var wait : boolean = true;
    3.  
    4.  
    5. //TOOLTIP
    6.  
    7. if(GUI.tooltip != ""){
    8.  
    9.     tooltipSize = myStyle.CalcSize(GUIContent(GUI.tooltip));
    10.     tooltipWait(3);
    11.     if(wait){
    12.         GUI.Label(Rect (Event.current.mousePosition.x-150,Event.current.mousePosition.y-100,tooltipSize.x+50,tooltipSize.y+50), GUI.tooltip, myStyle);
    13.         }
    14.     }
    15. }
    16.  
    17. public function tooltipWait (seconds : float) {
    18.     wait = false;
    19.     yield WaitForSeconds(seconds);
    20.     wait = true;
    21.     }
    22.  
    23.  
    It doesn't appear... :cry:

    Thanx for the help...
     
  2. bloodtiger10

    bloodtiger10

    Joined:
    Nov 9, 2008
    Posts:
    619