Page 1 of 1
NGUI Setup question
Posted: Tue Jan 19, 2016 12:04 am
by Bluerex
Hi,
I have a few questions... my game uses NGUI and I've got the dialog system working with it, but my response buttons are unclickable. Also, the NPC conversation text disappears when it comes time to respond... how do I make it persist?
Here's some screenshot info for you so you can see my setup:
This is the setup I'm using
This is the runtime
Any help is appreciated.
Re: NGUI Setup question
Posted: Tue Jan 19, 2016 10:26 am
by Tony Li
Hi,
On your NGUI Dialogue UI component:
1. Expand Response Menu.
2. Assign your NPC Panel and NPC Subtitle UI elements to the Subtitle Reminder section. So NPC Panel and NPC Subtitle will be doubly-assigned to NPC Subtitle and Response Menu > Subtitle Reminder. The Dialogue System shows the NPC Subtitle when delivering a line of dialogue. When showing a response menu, it hides the NPC Subtitle and shows the Subtitle Reminder. If the same UI elements are assigned to both, the net effect is that they remain visible.
3. Assign your buttons to the Buttons list if they're not already assigned. If the buttons still aren't clickable, pause the game while the response menu is visible. Inspect one of the buttons to see if the inspector gives you any insight into why the button isn't clickable.
Do the buttons look disabled, or do they look enabled but you just can't click on them? If they look enabled, maybe another invisible UI element is on top of them, blocking mouse clicks.
If you get stuck, please feel free to send an example project to tony (at) pixelcrushers.com. I'll be happy to take a look!
Re: NGUI Setup question
Posted: Tue Jan 19, 2016 3:23 pm
by Bluerex
Ok I've made some progress. The camera needed to be set to 3d World for the button clicks to register, which I have working now. I've also got the NPC Subtitle text working.
My only issue now is that the response buttons OnClick events aren't being set to anything. I assumed this would be set with the Response Button Script, but it isn't. The script is changing the button label though so I know it's hooked up correctly.
So do I have to manually handle the button OnClick event, or is the Response Button script supposed to set it for me?
Re: NGUI Setup question
Posted: Tue Jan 19, 2016 9:40 pm
by Tony Li
Hi,
NGUI automatically calls OnClick on any scripts on a button (such as the NGUI Response Button script). You don't need to manually add a handler.
Are there any warnings in the Console view, such as "You can't place widgets on a layer different than the UIPanel that manages them"? This will make a button unclickable, since NGUI only checks the UIPanel's layer.
Does the example scene work? (Dialogue System/Third Party Support/NGUI/Example/Feature Demo Using NGUI)
As another test, temporarily add another UIButton to your dialogue UI. Don't associate it with any fields in the NGUI Dialogue UI component. When you start a conversation, you should be able to click this button. It won't do anything, but you should still be able to click it. If you can't, then try to identify why it's not clickable -- maybe the layers are wrong (check the layers on your NGUI camera's Camera and UICamera components), maybe a transparent UIPanel is on top of it blocking clicks, etc. Once you get it to be clickable, the response buttons will probably also be clickable.