make Menu Text highlighting show Dialogue Text

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Munion
Posts: 4
Joined: Wed Mar 04, 2015 3:19 pm

make Menu Text highlighting show Dialogue Text

Post by Munion »

I haven't started creating it yet so forgive me if it is obvious, but I didn't see an obvious way when glancing at it.







When creating my own UI, is there a way to have dialogue text pop up in a new window when the response option(menu text) is highlighted?  For our game we want simple few word descriptions of responses similar to games like Mass Effect.  However we want to avoid some of the surprises Mass Effect had where a seemingly simple dialogue option could result in some unexpected dialogue from your main character.  LA Noire also had some issues with these kinds of surprises.  Our simple solution is to have the full dialogue appear when highlighting your choice.  However, on immediate looks I am not seeing a way to make this happen.  I figure it's doable tho...



It looks like maybe I would maybe want to have the player subtitle window displayed while having my response window up, yet I want the subtitle window to show what I am currently highlighting.   Again sorry if this will be completely obvious once I'm mid creating the UI.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

make Menu Text highlighting show Dialogue Text

Post by Tony Li »

The UI part is decoupled from the rest of the Dialogue System, so you can do whatever you want with your UI. If it diverges too much from any of the provided UI implementations, you'll have to create a subclass to override functionality or replace it entirely.



Another team did something similar last year. They created a subclass and added some extra functionality to the ShowResponses() method. I don't know which GUI system you're using, so I'll assume Unity UI (the new UI in 4.6 and 5.0).



I recommend not using the player subtitle panel; that may get confusing. Instead, add a new Text element to the response panel and style it however you want. Let's say you name it FullResponseText.



On each response button, replace the UnityUIResponseButton script with a script similar to the one below:

using UnityEngine;

using UnityEngine.UI;

using UnityEngine.EventSystems;

using PixelCrushers.DialogueSystem;



public class CustomResponseButton : UnityUResponseButton, ISelectHandler {

public Text fullResponseText; // Assign FullResponseText element.

public string dialogueText;



public void OnSelect(BaseEventData eventData) {

fullResponseText.text = dialogueText;

}

}



Then add an EventTrigger to the button. Add a new "Select" event, and point it to the OnSelect method in the script above.



What this does: When the player selects a button (i.e., hovers or uses key/gamepad navigation), it will set FullResponseText to the full dialogue text associated with the button's response.



Finally, create a subclass of UnityUIDialogueUI:

using UnityEngine;

using UnityEngine.UI;

using PixelCrushers.DialogueSystem;



public class CustomDialogueUI : UnityUIDialogueUI {

public Text fullResponseText; // Assign FullResponseText element.



public void override ShowResponses(Subtitle subtitle, Response[] responses, float timeout) {

base.ShowResponses(subtitle, responses, timeout);

// If you use button template, replace "buttons" below with "instantiatedButtons":

foreach (var button in dialogue.responseMenu.buttons) {

(button as CustomResponseButton).dialogueText = button.response.destinationEntry.DialogueText;

}

fullResponseText.text = string.Empty;

}

}

On your dialogue UI GameObject, replace UnityUIDialogueUI with this script.



What this does: When it shows the response menu, it also associates the full dialogue text with each button.



You can also do other things in CustomResponseButton's OnSelect method. I'm not sure what additional things the other team ended up doing, but I had suggested changing the facial animation (e.g., a mean face for a mean response, a fearful face for a fearful response, etc.). You can define a custom dialogue entry field to store the the name of the animation that the response should play.
Post Reply