How to get last line (entry)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
gourangas
Posts: 10
Joined: Mon May 04, 2020 9:59 am

How to get last line (entry)

Post by gourangas »

Hey Tony,

So I've got setup a series of monologues (only a narrator talks) for a puzzle game. Each puzzle starts with a dialogue entry and I've also set up a continue button to cycle through the lines (for that puzzle). I'm starting the conversation calling OnUse() from my dialogue trigger component, the correct starting entry is selected via a condition (i.e. "PuzzleID" == 5)that is present in all the starting entries.

Now my question is; how do I know if the current entry is the last one (meaning it has no follow up) ? I want to know this because I have to change the text from my continue button from saying "Next" to "Close" if the entry is the last one for that puzzle.
Also its such a pain in the a@@ to access the continue button since there is no reference of it anywhere (it only has the StandardUIContinueButtonFastForward component and that does all the job :) ).

This should help with explanation
https://ibb.co/nzB7zsn
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get last line (entry)

Post by Tony Li »

Hi,
gourangas wrote: Mon Oct 26, 2020 10:46 amNow my question is; how do I know if the current entry is the last one (meaning it has no follow up) ? I want to know this because I have to change the text from my continue button from saying "Next" to "Close" if the entry is the last one for that puzzle.
Check if DialogueManager.currentConversationState has any responses. For example, add a script with a method like this to the Dialogue Manager or dialogue UI:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    var continueButtonText = DialogueManager.currentConversationState.hasAnyResponses ? "Next" : "Close";
    var continueButton = (DialogueManager.dialogueUI as StandardDialogueUI).conversationUIElements.defaultNPCSubtitlePanel.continueButton;
    continueButton.GetComponent<Text>().text = continueButtonText;
}
Side note: If you are localizing your game, you can add fields named "Next" and "Close" to a text table asset. Assign the text table to the Dialogue Manager's Localization Settings. Then change the last line to:

Code: Select all

continueButton.GetComponent<Text>().text = DialogueManager.GetLocalizedText(continueButtonText);
gourangas wrote: Mon Oct 26, 2020 10:46 amAlso its such a pain in the a@@ to access the continue button since there is no reference of it anywhere (it only has the StandardUIContinueButtonFastForward component and that does all the job :) ).
The subtitle panel has a reference to the continue button. See my code example above.
gourangas
Posts: 10
Joined: Mon May 04, 2020 9:59 am

Re: How to get last line (entry)

Post by gourangas »

Hey,
Great info, everything works. The only problem is that OnConversationLine() doesn't really get triggered on each line :). OnConversationStart() does not trigger as well.... so I'm always missing the first line.

What I did is I inherited the StandardUISubtitlePanel in my PanelController, so that's where these 2 methods are placed.
Any idea of how to call OnConversationStart()? My guess is that the monobehaviour that contains the method must be attached to the transform that started the conversation?

Thanks in advance
gourangas
Posts: 10
Joined: Mon May 04, 2020 9:59 am

Re: How to get last line (entry)

Post by gourangas »

Ok so I've discovered the DialogueSystemEventsComponent and I'll use that. If you still want to answer with a different solution (probably the correct one, cause I feel like I am patching up a ship that's going to wreck soon :)) ) I'd be glad to hear it.

Have a nice day and great job with this tool man!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get last line (entry)

Post by Tony Li »

Hi,

This table explains which GameObjects get OnConversationStart and OnConversationLine messages. The messages are only sent to specific GameObjects to avoid spamming the entire scene. I recommend putting your script on the Dialogue Manager if you want it to always receive the message, or a character such as the player GameObject if you only want it to receive the message when that character is involved in the conversation. Dialogue System Events uses the same message system, so it must be on the same objects listed in the table.

Alternatively, you can register for conversation start/end C# events, which will be called regardless of which GameObject it's on. There isn't a C# event equivalent for OnConversationLine.
Post Reply