Author Topic: Ngui Button script question  (Read 2889 times)

bloobmob

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Ngui Button script question
« on: April 27, 2014, 02:12:34 AM »
When I use the button script is there a way to leave the button pressed and the unpressing it?

Sahkan

  • Jr. Member
  • **
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 74
    • View Profile
Re: Ngui Button script question
« Reply #1 on: April 27, 2014, 11:31:02 AM »
You can use an extra object ( Let's say an empty ) which will hold a boolean and will change it's property each click .
And just put that object in the UIButton section in the Button object ( In "On Click -> Notify" ) and then chose the function which change the variable for that boolean in the method section that will open gor you ones you drug the new object in it .

In the new object you should put some function like that :

  1. bool Clicked = false;
  2.  
  3. public void BoolChanger() //make sure to make the function public so you can access it via the inspector !
  4. {
  5. if(Clicked)Clicked = false;
  6. if(!Clicked)Clicked = true;
  7. }
  8.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Ngui Button script question
« Reply #2 on: April 27, 2014, 11:56:49 PM »
Leave the button pressed? That sounds like a toggle, not a button.