Search Unity

Click On GUI.Label

Discussion in 'Immediate Mode GUI (IMGUI)' started by mnrabaglia1234, Nov 26, 2009.

  1. mnrabaglia1234

    mnrabaglia1234

    Joined:
    Jul 27, 2009
    Posts:
    15
    Is there any possibility to catch an OnClick event in a GUI.Label?
     
  2. KaelisAsur

    KaelisAsur

    Joined:
    Apr 9, 2009
    Posts:
    361
    You could utilize the Rect used for specifying GUI.Label position/dimensions to check whether the mouse pointer is hovering over your label, then check if user has pressed a mouse button.
     
  3. Molix

    Molix

    Joined:
    Apr 24, 2009
    Posts:
    92
    Just use a GUI.Button that is drawn in the Label style.

    i.e.

    Code (csharp):
    1. if( GUI.Button("My clickable label", "Label" ) )
    2. {
    3.   Debug.Log("You clicked my label!");
    4. }
     
    CrazyD0G, UnityLighting and Xitech_ like this.