Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: zippo227 on September 16, 2016, 09:44:56 AM

Title: Allow UIButton and UIInput to receive a click.
Post by: zippo227 on September 16, 2016, 09:44:56 AM
I have a UIButton that interacts with my custom UIInput. When the user clicks outside of the UIInput, I want to hide that UIButton, unless, the click was on the UIButton. It's pretty important for the functionality of my input. I don't want to have all the extra buttons showing unless the user currently is interacting with the input.

protected override void OnSelect(bool isSelected)
{
      base.OnSelect(isSelected);

      extraButton.SetActive(isSelected);
}

The problem is, the UIInput receives the click first, which disables the UIButton and prevents it from ever being able to receive a click. I've tried setting alpha to 0 and scale to 0, and other such tricks, but nothing seems to work. How can I implement this?
Title: Re: Allow UIButton and UIInput to receive a click.
Post by: ArenMook on September 17, 2016, 12:25:31 AM
Don't listen to the OnSelect notification. Subscribe to UICamera.onSelect instead. It's a generic delegate that will be called regardless of what's selected, letting you decide what happens.
Title: Re: Allow UIButton and UIInput to receive a click.
Post by: zippo227 on September 21, 2016, 01:46:03 PM
Thanks for this! It worked great. I set a tag on the game objects that I want to be able to click and check that tag in the OnSelect delegate.

(When I tried to post the code I wrote as an example I got this error. "You don't have permission to access /forum/index.php on this server"
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.)  :o
Title: Re: Allow UIButton and UIInput to receive a click.
Post by: ArenMook on September 23, 2016, 03:45:53 PM
Yeah the forum here seems to reject some code segments that it believes may be database queries or something...
Title: Re: Allow UIButton and UIInput to receive a click.
Post by: zippo227 on September 23, 2016, 05:28:05 PM
OK here's a link to a pastebin of it.

http://pastebin.com/cjbJFGg0 (http://pastebin.com/cjbJFGg0)