Page 1 of 1
How to get reference of the Response Button generated by dialogue system
Posted: Mon Feb 12, 2024 1:22 pm
by hyf4053
Hello! Here is the situation. I would like to know how to get the reference of the response button generated by the template in the standard UI. Since I need to add a tooltip when the mouse cursor hovers on the response button and not all the response buttons need a tooltip. So I wrote a script for the button template, however, I just could not figure out how to tell the script on the button that the response needs a tooltip when the mouse cursor is on it. Because some information about the context of the tooltips is written in the dialogue, so I need to tell the tooltip the context to display through the dialogue. Is there any way to easily get the reference of the generated response button to tell each button's tooltip what to display? Thanks in advance!
Re: How to get reference of the Response Button generated by dialogue system
Posted: Mon Feb 12, 2024 2:47 pm
by Tony Li
Hi,
The cleanest way is to make a subclass of
StandardUIResponseButton and use the subclass in place of StandardUIResponseButton on your response buttons.
Override the SetFormattedText() method and access the response property. For example, say the response dialogue entry has a field named "Tooltip":
- tooltipField.png (14.13 KiB) Viewed 105 times
(I trimmed some irrelevant fields from the screenshot above.)
Then your overridden method might look like:
Code: Select all
public override void SetFormattedText(FormattedText formattedText)
{
base.SetFormattedText(formattedText);
var tooltip = Field.LookupValue(response.destinationEntry.fields, "Tooltip");
if (string.IsNullOrEmpty(tooltip))
{
ClearTooltip();
}
else
{
SetTooltip(tooltip);
}
}
Re: How to get reference of the Response Button generated by dialogue system
Posted: Tue Feb 13, 2024 12:07 am
by hyf4053
Tony Li wrote: ↑Mon Feb 12, 2024 2:47 pm
Hi,
The cleanest way is to make a subclass of
StandardUIResponseButton and use the subclass in place of StandardUIResponseButton on your response buttons.
Override the SetFormattedText() method and access the response property. For example, say the response dialogue entry has a field named "Tooltip":
tooltipField.png
(I trimmed some irrelevant fields from the screenshot above.)
Then your overridden method might look like:
Code: Select all
public override void SetFormattedText(FormattedText formattedText)
{
base.SetFormattedText(formattedText);
var tooltip = Field.LookupValue(response.destinationEntry.fields, "Tooltip");
if (string.IsNullOrEmpty(tooltip))
{
ClearTooltip();
}
else
{
SetTooltip(tooltip);
}
}
Thank you Tony, this is helpful!
Re: How to get reference of the Response Button generated by dialogue system
Posted: Tue Feb 13, 2024 9:00 am
by Tony Li
Glad to help!