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

C#, GUI.Button variable assigning

Discussion in 'Scripting' started by Findo, Apr 8, 2014.

  1. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    Is there anyway that I could assign a variable to a gui.button and check for clicking?

    like...


    Would that work?
     
  2. barinelg

    barinelg

    Joined:
    Jun 1, 2010
    Posts:
    95
    GUI.Button returns a boolean, so if(GUI.Button(...)) { } should work.
     
  3. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    But I want to assign a variable, then check.
    how is this done?
     
  4. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    It would work if you change the type of My_Button. Look at the return type of the Button function. It returns a bool, not a GUI.
     
    Pharaoh_ likes this.