Use UI With Our Own Dialogue Engine

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
MoRifRaf
Posts: 1
Joined: Tue Dec 03, 2019 5:02 pm

Use UI With Our Own Dialogue Engine

Post by MoRifRaf »

Hello there. We've rolled our own dialogue system/engine as far as keeping track of conversations, what people say, responses, etc. However, we've been using our own debug/horrible looking UI just to have something to visualize it to make sure it works. However, we really like how your UI looks/behaves. Is there a way that we could use our own rolled dialogue system and somehow plug it into your UI for visualization? Like for example re-writing our own StartConversation() function to fill in all the data from our stuff instead of pulling it from the DSFU master database.
Thanks!
-Mo
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Use UI With Our Own Dialogue Engine

Post by Tony Li »

Hi Mo,

Usually it goes the other way if at all, where a dev points the Dialogue System's engine output to their own custom UI. However, this is similar to what the Dialogue System's Ink integration does, so it's certainly possible.

First get a reference to your dialogue UI (i.e., StandardDialogueUI class).

Call its Open() method to open the dialogue UI.

To show a subtitle, call ShowSubtitle(Subtitle subtitle). You'll need to create a Subtitle object. To hide it, call HideSubtitle(Subtitle subtitle) with the same object.

To show a response menu, call ShowResponses(Subtitle subtitle, Response[] responses, float timeout). You'll need to create an array of Response objects. If you don't want the menu to be timed, pass zero for timeout. To hide the menu, call HideResponses().

When the player clicks on a response button, it normally calls back to the engine to decide what to show next. You'll want to tell it to call back to your own method instead. To do this, assign your method to the dialogue UI's SelectedResponseHandler delegate. For example, something like this:

Code: Select all

void OnConversationStart(Transform actor)
{
    var dialogueUI = DialogueManager.dialogueUI as StandardDialogueUI;
    dialogueUI.SelectedResponseHandler = OnSelectedResponse;
}

void OnSelectedResponse(object sender, SelectedResponseEventArgs args)
{
    Debug.Log("Player selected response: " + args.response);
}
When you're done with the conversation, call the dialogue UI's Close() method.
Post Reply