Unique Response Metadata

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Unique Response Metadata

Post 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!
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: Unique Response Metadata

Post 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.
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Unique Response Metadata

Post 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")
}

}
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: Unique Response Metadata

Post by Tony Li »

Yup, that's how it's done! Thanks for sharing your code.
Post Reply