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. |
Route 1: a window prefab
Section titled “Route 1: a window prefab”- Build a prefab with a
DialoguePanelon 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. - Create a Dialogue Style with Create > MrW > Intrigues > Dialogue Style, or open one you have.
- Drag your prefab into Window. Empty means the Dialogue Manager’s window.
- 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.
Route 2: draw it yourself
Section titled “Route 2: draw it yourself”- Write a class that implements
IDialogueView. It has one method,void Show(DialogueModel dialogue). It is called once per dialogue or announcement. - Draw
dialogue.Title,dialogue.PlainTextanddialogue.Choices. For a choice, callchoice.Pick()when the player clicks. - Listen to
dialogue.Closedand take the window away. - 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.
What can go wrong
Section titled “What can go wrong”- Your view throws in
Show: the dialogue closes at once with the reasonCode. - 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.