Thanks so much!
Licensing wise, do you mind if I just copy & paste some of the code from your example into my own code?
Getting and sending responses through code
Re: Getting and sending responses through code
Sure, have at it!
Re: Getting and sending responses through code
I have discovered a new problem. There are only ever 3 (invisible) response buttons at a time, even if the number of responses I've written is higher. Is there a way I can have it generate as many buttons as there are responses? I currently have it set to using the Bubble Menu panel for responses like in the example scene you posted.
Also, how do I turn off the fade in/fade out effect on the speech bubbles? I saw in another thread that the answer was to change the show/hide trigger to being blank, but this resulted in the bubble just not becoming visible at all.
Also, how do I turn off the fade in/fade out effect on the speech bubbles? I saw in another thread that the answer was to change the show/hide trigger to being blank, but this resulted in the bubble just not becoming visible at all.
Re: Getting and sending responses through code
Hi Luke,
If you're using the bubble UI prefab in the Prefabs folder, or the bubble UI in the Bubble Subtitle Example, they're only designed with 3 buttons. You can configure response menus to use a list of explicitly-placed buttons (like in these bubble UIs) or instantiate as many buttons as needed from a template button and put them into a layout group container (like in most of the other UI prefabs such as Basic Standard Dialogue UI). If you need more than 3 buttons, here are 2 options:
1. Add more explicitly-placed buttons to the StandardUIMenuPanel's Buttons list.
2. Or remove the buttons, keeping just one to use as a template, and assign it to the Button Template field. Set up a container panel that will hold copies of this button, and assign it to the Button Template Holder field. Clear the Buttons list. When setting up the response menu, the Dialogue System will instantiate as many copies of the template button as needed and put them all in the Button Template Holder.
To turn off the fade in/out on the bubbles, remove the Animator from the Bubble Panel child GameObject, and also clear the Show and Hide Trigger fields.
If you're using the bubble UI prefab in the Prefabs folder, or the bubble UI in the Bubble Subtitle Example, they're only designed with 3 buttons. You can configure response menus to use a list of explicitly-placed buttons (like in these bubble UIs) or instantiate as many buttons as needed from a template button and put them into a layout group container (like in most of the other UI prefabs such as Basic Standard Dialogue UI). If you need more than 3 buttons, here are 2 options:
1. Add more explicitly-placed buttons to the StandardUIMenuPanel's Buttons list.
2. Or remove the buttons, keeping just one to use as a template, and assign it to the Button Template field. Set up a container panel that will hold copies of this button, and assign it to the Button Template Holder field. Clear the Buttons list. When setting up the response menu, the Dialogue System will instantiate as many copies of the template button as needed and put them all in the Button Template Holder.
To turn off the fade in/out on the bubbles, remove the Animator from the Bubble Panel child GameObject, and also clear the Show and Hide Trigger fields.
Re: Getting and sending responses through code
Thanks! I got those things working now, but unfortunately it broke something else. I switched to instantiated buttons since the number of responses will be varying quite a bit, but the StandardUIMenuPanel.buttons that I was iterating through to find a match is now empty. The buttons show up now in StandardUIMenuPanel.instantiatedButtons, but they don't have OnClick() available. Is there another way to access them?
I suppose I could get a reference to the game object that is the parent of the buttons and iterate through its children instead, but it seems like there is probably a better way.
I suppose I could get a reference to the game object that is the parent of the buttons and iterate through its children instead, but it seems like there is probably a better way.
Re: Getting and sending responses through code
Hi,
StandardUIMenuPanel.instantiatedButtons is a list of GameObjects. Each one will have a StandardUIResponseButton component that you can access using GetComponent():
(It's a list of GameObjects instead of a list of StandardUIResponseButtons to make it more concise for StandardUIMenuPanel to manage their instantiation.)
StandardUIMenuPanel.instantiatedButtons is a list of GameObjects. Each one will have a StandardUIResponseButton component that you can access using GetComponent():
Code: Select all
foreach (var buttonGO in myMenuPanel.instantiatedButtons)
{
var button = buttonGO.GetComponent<StandardUIResponseButton>();
Debug.Log("Button is linked to response: " + button.response.formattedText.text);
}
Re: Getting and sending responses through code
Ok, thanks! I've got it working now.
Re: Getting and sending responses through code
Great! Glad to help.