Skip to content

Use my own dialogue window

Goal: dialogues appear in a window that looks the way you want.

There are two routes. Pick the lighter one that does the job.

Route Use it when What you write
A window prefab on a style You can build the window from Unity UI (uGUI) pieces. A prefab with a Dialogue Panel, and optionally a subclass.
IDialogueView Your game has its own UI technology, such as UI Toolkit, IMGUI or a 3D speech bubble. One class with one method.
  1. Build a prefab with a DialoguePanel on it. The title label, the text label and the choice template (choiceLayout) are required. Every other slot is optional: the countdown label, the picture, the frame, the speaker’s name and portraits, the continue sign.
  2. Create a Dialogue Style with Create > MrW > Intrigues > Dialogue Style, or open one you have.
  3. Drag your prefab into Window. Empty means the Dialogue Manager’s window.
  4. Name that style in a Show Dialogue node, or make it the Default Style of the Intrigue Manager.

You will see: dialogues of that style open in your window. The Dialogue Manager keeps copies of the window in pools and fills one for every dialogue. A click on the window that is not on a choice or a name finishes the part of the text being written.

For a window with a new behaviour, derive from DialoguePanel. Show, Hide, Apply and SetSpeaker can be overridden. They are protected internal virtual in DialoguePanel.cs.

  1. Write a class that implements IDialogueView. It has one method, void Show(DialogueModel dialogue). It is called once per dialogue or announcement.
  2. Draw dialogue.Title, dialogue.PlainText and dialogue.Choices. For a choice, call choice.Pick() when the player clicks.
  3. Listen to dialogue.Closed and take the window away.
  4. Install the view once, for example in Awake: IntrigueUI.Dialogues.Use(new MyDialogueView());. Use(null) brings the ready-made window back.

Example. Compiled against the package’s runtime assembly; not run in Unity. The interface is in the namespace MrW.Intrigues.UI; the class name is yours:

public sealed class MyDialogueView : IDialogueView
{
public void Show(DialogueModel dialogue) { /* draw it */ }
}

The full example, the model’s members and the rules for writing text at your own pace are on Your own dialogue window.

  • Your view throws in Show: the dialogue closes at once with the reason Code.
  • You hold the choices while the text is written and never release them: they are released after 120 seconds of real time, with a warning. Call ReleaseChoices.
  • With your own view, the style’s cue sounds are not played, and all cues come at once when the text counts as written.
  • The prefab is ignored: the style asset is not the one your node names, or the style’s Window is empty.
  • The Intrigue Manager is still required with a view installed.

See also Dialogue Style, Dialogues and announcements and IntrigueUI from code.