Search Unity

Gui button up?

Discussion in 'Scripting' started by yoash, Aug 28, 2015.

  1. yoash

    yoash

    Joined:
    Sep 3, 2013
    Posts:
    36
    Code (CSharp):
    1. public void OnGUI(){
    2.         if (GUI.Button (new Rect (Screen.width * 0.85f, Screen.height * 0.05f, Screen.width * 0.10f, Screen.width * 0.05f), "Go")) {
    3.             print ("button down");
    4.         } else {
    5.             print ("button up");
    6.         }
    I am trying to detect when a GUI button is held down, and when it is not currently being held down.. Anyone know how this works in C#?

    Thanks
     
  2. OneDragutin

    OneDragutin

    Joined:
    May 10, 2015
    Posts:
    315
    Code (CSharp):
    1. if(Event.current.type == EventType.MouseDown && rect.Contains(Event.current.MousePosition))
     
    yoash likes this.
  3. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,175
    Gui. RepeatButton
     
    yoash likes this.