Page 1 of 1

Get Dialogue Entry Field for Response

Posted: Thu Jul 14, 2022 3:48 pm
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?

Re: Get Dialogue Entry Field for Response

Posted: Thu Jul 14, 2022 4:03 pm
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);
        }
    }
}

Re: Get Dialogue Entry Field for Response

Posted: Thu Jul 14, 2022 4:29 pm
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 :)

Re: Get Dialogue Entry Field for Response

Posted: Thu Jul 14, 2022 4:41 pm
by Tony Li
Great! Glad to help.