Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to define that a button is a toggle? -> use Normal and OnNormal

Discussion in 'Immediate Mode GUI (IMGUI)' started by BooBi, Nov 11, 2010.

  1. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    Hi,

    Before, the previous post about On active and active in guistyle, I was using a piece a script with 3 Gui style, (the active state one, the non active state, and the style used in the scene).

    I would like to know how can I define my GUI.button(rect, "", myGuistyle); as a button which use 2 states ?

    thank's


    BooBi
     
  2. polyphobia3d

    polyphobia3d

    Joined:
    Nov 7, 2010
    Posts:
    13
    well you could use GUI.toggle, but so far i couldn't find how to hide the toggle button and use an image instead
     
  3. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    use GUI.toggle and style it as a button.
     
  4. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    It seems that there is a problem here,

    I want a button, with 2 textures (for the button so one on, one off)

    When I click on the button I what it to do what's in the if(GUI.button...){ Do my thing }, and use the OnActive/OnNormal/... textures.
    Then If i click again on it, do what's in my if again, and use my Active/Normal/... textures.

    What's the boolean for ? (in the toggle), I don't want to turn on and off my button (like enable/disable the button) I want to change his state, activate or non activate.

    Do someone knows how to do that ?
     
  5. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    Ok found the solution cheers for the help.