Search Unity

GUI Popup won't work in conjunction with mouseOver AND Mouse Click ?

Discussion in 'Scripting' started by Digital-Phantom, Dec 20, 2014.

  1. Digital-Phantom

    Digital-Phantom

    Joined:
    May 31, 2013
    Posts:
    42
    I have a GUI Texture popup that is supposed to work when the player does a mouseOver on a certain object and clicks the mouse button.

    It works fine as just a simple popup on mouseOver BUT... I only want the popup to happen when the player/cursor hovers over the object AND clicks the mouse button

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. private var pressedButton : boolean = false;
    4. public var Clue01GUI: Texture;
    5.  
    6. function OnMouseOver()
    7. {
    8.     pressedButton = true;
    9. }
    10.  
    11. function OnMouseExit()
    12. {
    13.     pressedButton = false;
    14. }
    15.  
    16. function OnGUI()
    17. {
    18.     if(pressedButton == true)
    19.     {
    20.         GUI.DrawTexture(Rect(350,95,300,410), Clue01GUI);
    21.     }
    22. }

    Any ideas guys?
     
    Last edited: Dec 20, 2014