Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Boomer on June 30, 2014, 12:36:51 AM

Title: How do you reference buttons in code?
Post by: Boomer on June 30, 2014, 12:36:51 AM
As per the title suggests, I've Googled this issue but cannot, for the life of me, figure out how to make references to my NGUI buttons in code.

For a little more information, I'm trying to make a GUI where when you click a button it pops up another button created with NGUI.  In order to do this I need to use Show and Hide commands within C#.  This, however, is proving difficult due to my inability to set calls to the buttons within the code itself.  I might be missing something simple, I suppose (very new to Unity.) 

Any assistance, or pointing towards something where I can help myself would be greatly appreciated.
Title: Re: How do you reference buttons in code?
Post by: ArenMook on July 01, 2014, 02:58:12 AM
Via code?
  1. UIEventListener.Get(buttonGameObject).onClick = YourCallback;
...or using the button component's on click notification (same as you see in inspector):
  1. EventDelegate.Set(GetComponent<UIButton>().onClick, YourCallback);