Search Unity

GUI Buttons MouseUp and MouseDown

Discussion in 'Immediate Mode GUI (IMGUI)' started by Smireles, Apr 27, 2009.

  1. Smireles

    Smireles

    Joined:
    Jun 20, 2008
    Posts:
    38
    Hello guys..

    Im trying to evaluate several conditions during the "clicking" cicle of a GUI button... in other words, i want to check stuff at OnMouseDown so i can do or not do more stuff at OnMouseUp...

    I can do this with 3d meshes... im already "using void OnMouseUp()" and "using void OnMouseDown()" there.

    The problem is at GUI components, when using:
    Code (csharp):
    1.  
    2. if(GUI.Button (new Rect (10f,10f,150f,80f), "Hola"))
    3. {
    4.     Debug.Log("Adios");
    5. }
    6.  
    So far, this is the only way i know to give actions to GUI.Button (im a noob). And the worst thing about this is that this only works on "onmouseup". I need to check some "if's" at "onmousedown" first!!!

    Please tell me a way to accomplish this.

    ----
    I have a temporal solution for this:
    Code (csharp):
    1.  
    2. if(Event.current.type==EventType.Used)
    3. {
    4.     Debug.Log("Wawawawa");
    5. }
    6.  
    This runs at mouseup as well as mousedown... and its doing the trick, but this will be a problem when i have more buttons on screen... i want to do things straight and clear.

    HALP!! plz

    ciao from mexico