Page 1 of 1

Unique Response Metadata

Posted: Tue Dec 01, 2020 11:01 pm
by ar4wy
Hi Tony,

(sorry me again) I'm trying to find a way to assign some sort of tag to a response menu, which I can then get when it is highlighted.

Ideally, the workflow would be me assigning this "tag" in the Dialogue Editor (maybe using description?), and then getting it when a response menu is highlighted, to check and to do something if the tag matches.

Something like:

OnSelect() response menu button, if "Response.DialogueEntry.Description" == tag, play specific sound.

Let me know if there is a way to do this or if you have any ideas!

Thanks!

Re: Unique Response Metadata

Posted: Wed Dec 02, 2020 7:31 am
by Tony Li
Hi,

The Dialogue System Extras page has a Hover Response Button Example that works similarly. A README file in the package explains how it works. It handles "pointer enter" events, although you could change that to "select" events. When the event occurs, the button looks up a custom field in its destination dialogue entry. You could use the Description field if you don't want to make a custom field.

Re: Unique Response Metadata

Posted: Wed Dec 02, 2020 7:15 pm
by ar4wy
Thanks, Tony!

For anyone looking at this thread in the future, the way I'm getting it is:

1. Adding a new field to the Dialogue Entry Template (under Templates in the Dialogue Editor)
2. Adding a script to the "Response Button Template" GameObject with an ISelectHandler and OnSelect().
3. In that script, in OnSelect(), I do this:

Code: Select all

public class MyScriptAttachedToResponseButtonTemplate : MonoBehaviour, ISelectHandler
{

private void OnSelect(BaseEventData eventData) 
{
var response = GetComponent<StandardUIResponseButton>().response;
print(Field.LookupValue(response.destinationEntry.fields, "New Field I Just Added")
}

}

Re: Unique Response Metadata

Posted: Wed Dec 02, 2020 7:26 pm
by Tony Li
Yup, that's how it's done! Thanks for sharing your code.