Get Dialogue Entry Field for Response

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
JuSt
Posts: 7
Joined: Wed Jul 13, 2022 6:49 pm

Get Dialogue Entry Field for Response

Post by JuSt »

Hi Tony,
sorry for one question after another.

I have a custom bool field for my dialogue entries called "HideWhenUnavailable". I'm trying to see if a response has this field set to True. However I'm only able to access the dialogue node the response appears in (the subtitle) or the dialogue entry it connects to (responses.destinationEntry), not the response itself as a dialogue entry.

Is there some way to access the response as a dialogue entry that I'm overlooking?
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: Get Dialogue Entry Field for Response

Post by Tony Li »

Hi,

A response isn't a dialogue entry. It's an object that encapsulates some menu text and the destination entry to use if the player chooses the response.

Is the purpose of HideWhenUnavailable to exclude the dialogue entry from the response menu? If so, you could make a subclass of StandardUIMenuPanel that overrides ShowResponses(). Something like:

Code: Select all

protected override void SetResponseButtons(Response[] responses, Transform target)
{
    // (Assumes we're using instantiated buttons.)
    base.SetResponseButtons(responses, target);
    foreach (var button in instantiatedButtons)
    {
        // If button in inactive because Conditions are false, hide it if HideWhenUnavailable is true:
        var responseButton = button.GetComponent<StandardUIResponseButton>();
        if (!responseButton.isClickable && Field.LookupBool(responseButton.destinationEntry.fields, "HideWhenUnavailable"))
        {
            button.SetActive(false);
        }
    }
}
JuSt
Posts: 7
Joined: Wed Jul 13, 2022 6:49 pm

Re: Get Dialogue Entry Field for Response

Post by JuSt »

Thanks Tony. It ended up working by using:

Code: Select all

Field.LookupBool(responses[i].destinationEntry.fields, "HideUnavailable")
as each player choice has its own node (with the custom field I want to check). i think I just got confused because I thought the responses themselves are the player choice nodes, but they actually are the links from the previous node to the player choice node. All working now :)
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: Get Dialogue Entry Field for Response

Post by Tony Li »

Great! Glad to help.
Post Reply