FAQ

Table of Contents

Topics


How do I do <X>?

  1. Search for the topic using the search bar in the upper right area of this manual.
  2. Check the questions on this FAQ page.
  3. Check the Recipes page for prewritten solutions.
  4. Post your question on the forum thread: http://forum.unity3d.com/threads/204752-Dialogue-System-for-Unity
  5. Contact us any time for support: http://www.pixelcrushers.com/support-form/

Writing Dialogue

How do I make text change dynamically during gameplay?

In your menu text and dialogue text, use the [var=varName] or [lua(code)] tag. During conversations, the [var=varName] tag will be replaced with the value of the named variable. The [lua(code)] tag will be replaced by the return value of the lua code. For example, to reference the player's age, you could use this Dialogue Text:

You're [lua(Actor["Player"].Age)]? You don't look a day over [lua(Actor["Player"].Age - 1)]!

What happened to the Video File field?

Version 1.0.5 and earlier repurposed Chat Mapper's built-in Video File field for cutscene sequences. Chat Mapper 1.6 introduced validation, which fails on the Video File field unless it's an actual video file, so the Dialogue System now uses a custom field called "Sequence".

Is it possible to make the player have a conversation with himself/herself?

Yes. Tick Show PCSubtitles During Line in the Dialogue Manager's Display Settings. If only one dialogue entry is valid each turn and it has no force tag ([f]), then the Dialogue System will go through them without displaying the menu.

What happens if a dialogue entry links to NPC entries and PC response entries?

In this case, the Dialogue System automatically selects the first valid NPC entry and does not display a PC response menu.

Can I place emphasis tags on a subset of text?

By default, the Unity GUI implementation of IDialogueUI applies the first emphasis tag to the entire line. If you want to use multiple tags in a single line, or have tags affect only a subset of the line, you can tell the Dialogue Manager to convert emphasis tags to rich text codes. To do this, tick Rich Text Emphases in the Dialogue Manager's Dialogue Manager Display Settings. Your dialogue UI must support rich text. (The provided Unity GUI prefabs all support rich text.)

Does the Dialogue System support voice-acted lines?

Yes. See How do I add voice acting?.

Can I prompt the player to input text during a conversation?

Yes. You can either use the [var=?varName] tag as described in Chat Mapper Tags or the TextInput().

How do I update the response menu while it's being shown?

Call DialogueManager.UpdateResponses() or use the equivalent PlayMaker or plyGame action. This updates the responses for the current state of the active conversation. If the response menu entries' conditions have changed while the response menu is being shown, you can call this method to update the response menu.

How do I go backward in a conversation?

Add a script that listens for OnConversationLine (see Script Messages), and record the line's dialogue entry ID. Examine ConversationLogger.cs for an example of listening for OnConversationLine. To go back, call DialogueManager.ConversationController.GotoState() to jump to a previous dialogue entry. Alternatively, just record the text in OnConversationLine and put it in a scrollback buffer. This will allow the player to scroll back and review the entire conversation transcript.

Why aren't the active GameObjects the same as the actors defined in my conversation?

At runtime, you can assign any two GameObjects as a conversation's current Actor and Conversant. For details, see How GameObjects Are Associated With Conversations.

Are Chat Mapper or articy:draft required?

No. You can use the Dialogue System's Dialogue Editor inside Unity. This built-in editor can create the exact same dialogue databases that you can with Chat Mapper, and in fact is easier for editing quest data. However, Chat Mapper is a professional grade tool and very good for serious dialogue authoring. It provides a simulator, a powerful validation tool, and much more to make authoring very easy.

Why does the Chat Mapper Converter fail?

You may be using Chat Mapper 1.6.0 - 1.6.1.0, which contains a bug in its XML exporter. Please upgrade Chat Mapper: http://www.chat-mapper.com/download


Barks

How can I make multiple NPCs bark at each other?

See the examples in Examples/Bark Example/Three NPCs Bark. In brief: In each NPC's bark entry, set the Sequence field to SendMessage(OnUse,,NPC), where "NPC" is the name of the next NPC to bark. (Note the two commas; the second parameter is empty.) You can also set a Lua variable in the Sequence so the next NPC knows what line to bark.

Barks

Yes. On the Bark Trigger, tick Allow During Conversations.


User Interfaces

Can I use the same GUI control for NPC subtitle and NPC subtitle reminder?

Yes. When switching from subtitles to response menu, the Dialogue System will deactivate the control and reactivate it in case you've attached any special effects that trigger when the game object is activated (e.g., fade in, typewriter animation, etc.).

How do I slow down or speed up how long the NPC's subtitles stay on screen?

You can choose from a few ways:

  1. In the Dialogue Manager's Display Settings, set "Subtitle Chars Per Second" to a lower number. It defaults to 30 characters per second. If you set it to 10, subtitles will display three times longer. (See Dialogue Manager Display Settings)
  2. In Display Settings, change the Default Sequence to something that runs longer. By default it does an immediate closeup on the speaker, then after "{{end}}" seconds it does a closeup on the listener. The string "{{end}}" is an alias for the duration of the subtitle based on Subtitle Chars Per Second. You could replace this with, say, 10 seconds, to always make all subtitles display for 10 seconds.
  3. Define a custom sequence for any dialogue entry that you want to last longer. The subtitle won't go away until the sequence is done.

Why doesn't my Unity UI Dialogue UI accept input?

If you're using Unity 2017.3 or higher, you may need to tick the Force Module Active checkbox on your Event System's input module.

How do I set up keyboard/gamepad navigation?

The dialogue UI implementations for each of the provided GUI systems provide a way to set up keyboard/gamepad navigation. See the specific details for each GUI system implementation in How to Set Up the Dialogue UI.

Why does my conversation skip the player response menu / exit immediately?

The Dialogue System uses the behavior established in Chat Mapper: if there's only one player line, it automatically plays that line instead of presenting a response menu. You can force the response menu by ticking the Dialogue Manager's Always Force Response Menu checkbox or by adding [f] to the text (e.g., "[f]Goodbye, friend.").

In addition, the Show PC Subtitles During Line checkbox is unticked by default. This means the Dialogue System doesn't display the PC's line onscreen. It immediately goes to the next line in the conversation. If there are no more lines along the current path of the conversation tree, the conversation will end immediately.

Also make sure that "Is Player" is true for the player actor.

How do I control what name is shown in the NPC/PC Portrait Name?

If the NPC or PC has an Override Actor Name component (accessible through Window > Dialogue System > Component > Supplemental), the override name is used. Otherwise, if the NPC or PC is associated with a GameObject (the default unless you manually call DialogueManager.StartConversation() from code without providing GameObjects), it will use the GameObject's name. If no GameObject is associated, it will use the name defined in the dialogue database.

Why isn't the continue button showing?

If you've set Dialogue Manager > Continue Button to anything but Never, the dialogue UI will look for a continue button control. Most of the provided UI prefabs do not define a continue button; you'll need to add one yourself. You can examine any of the prefabs that end in "With Continue Button" to see how they're set up.

How can I make the continue button fast forward the typewriter effect?

If you're using Unity Unity UI Dialogue UI with a typewriter effect and a continue button, use the Continue Button Fast Forward component to change the behaviour. Please read the Continue Button Fast Forward documentation to configure it properly.

(2D Toolkit) Why is my subtitle and/or response text cut off?

2D Toolkit uses tk2dTextMeshes to display text. You must specify a maximum number of characters for each one. If your text is getting cut off, increase the value on your tk2dTextMesh.

(2D Toolkit) Why are my UI controls too big/small?

If you based your UI design off the included TK2D UI prefab, check the dimensions of the ButtonGraphics' tk2dSlicedSprite components. These are set to values that probably aren't the same as your UI images.

How can I add additional functionality to dialogue UIs?

The Unity, DFGUI, and TK2D dialogue UIs all derive from AbstractDialogueUI. You can create a subclass of the dialogue UI (e.g., public class ExtendedDaikonForgeDialogueUI : DaikonForgeDialogueUI {}) and override methods such as ShowSubtitle() and ShowResponses() to do extra things. See Subclassing An Existing Dialogue UI System for more details.

If that's not enough, you can always write your own UI that implements IDialogueUI. In the Dialogue System, UIs are decoupled from data and logic; you're not tied to any specific UI implementation. See Creating Your Own Dialogue UI for more details.

Why does my UI only show up in the left camera of my Oculus VR headset?

Unity GUI renders to screen space, not world space. If you use a different GUI system such as NGUI, DF-GUI, or TK2D that renders to world space, the GUI will work with Oculus VR. If you want to stick with Unity GUI, you can do what OVRMainMenu.cs does and render to a RenderTexture that's visible in world space (e.g., on a quad in front of the camera).

How do I pause a conversation?

See How do I pause the Dialogue System?.

Can I set up the dialogue UI with a scrollable history of the conversation?

Yes. The Dialogue System Extras page contains an example (under the UIs section) that demonstrates this.

Using Unity UI, how do I fix a "layout rebuild while already inside layout rebuild loop" error?

Locate the offending Scroll Rect and set its Vertical and/or Horizontal scroll bar Visibility dropdowns to Auto Hide.


Cutscene Sequences & Delivering Dialogue Lines

Why is there a two second delay at the beginning of the conversation?

Every conversation starts with dialogue entry titled START. This entry has a Sequence just like all other entries. If the Sequence is blank, it uses the default sequence, which includes a 2+ second delay. To immediate progress past the START entry, set its Sequence to "None()". Since version 1.1.3, the dialogue database editor now sets the START entry's Sequence to "None()" for new conversations by default.

Why aren't Camera() commands working?

If the camera moves into the specified position then immediately swings back to "gameplay mode," your gameplay camera controller is probably taking control of the camera. For the solution, see How do I stop gameplay activity during conversations?.

If the camera doesn't move to the specified camera angle at all, make sure the camera angle is defined in the Camera Angles object/prefab assigned to your display settings. The angle might be missing the angle or you could have a typo. (See Sequencer Camera)

How do I prevent the Dialogue System from controlling the camera?

On the Dialogue Manager object, change Display Settings > Camera Settings > Default Sequence to Delay({{end}}) to make each line delay before proceeding, or None() to show the line and proceed immediately to the next line or response menu.

Why does the screen immediately immediately visible right after Fade(out) finishes?

Fading works by covering the screen with a GUITexture (black by default). Fade(in) changes the alpha value from 1 (opaque) to 0 (invisible). Fade(out) does the opposite. At the end of the command, the GUITexture is destroyed as a safeguard. Otherwise you could leave the player with a black screen. If you need to do a set change, try to fade out and back in during the same sequence, starting the fade-in just before fade-out is done. If this isn't possible, then create a black GUITexture in the scene. Leave it inactive. In the first sequence, use SetActive() to activate it. In the second sequence, use SetActive() to deactivate it. However, in this case, you really need to be sure that the second sequence runs; otherwise you'll be stuck with a black screen.

Why does my OnStart sequence wait one frame to start?

This is most noticeable with the Fade(in) command, since the scene will be visible for one frame before going black and fading in. The solution is to untick Wait 1 Frame on the Sequence Trigger. By default this is ticked to allow other GameObjects to finish their Start() methods in case the sequence references those GameObjects. If you're not going to reference other GameObjects immediately in your sequence, you can untick it.

How do I set a different default sequence for a conversation?

Normally, conversations use the Dialogue Manager's Default Sequence. To specify a different default sequence for a specific conversation, add an Override Display Settings component to the conversant.

My game uses an orthographic camera. How do I do cutscenes?

If you want to use a perspective camera for cutscenes, set it up and assign it to the Dialogue Manager's Sequencer Camera property. For more information, see Sequencer Camera.

What runs first – a dialogue entry's user script or sequence?

The user script runs first. This way, your user script can set up variables that your sequence might need to reference.

How do I add voice acting?

The Dialogue System was originally developed for a voice-acted RPG, so support for voice acting is a core design feature. The Dialogue System doesn't analyze audio or generate lip sync animation. Use a tool such as FaceFX, iClone, or Mixamo's FacePlus for that. In the Dialogue System, you can associate a cutscene sequence with every line of dialogue. (If you're using localization, you can associate sequences for each language, too.)

If you're using FaceFX's XML curves, use the FaceFX() command.

If you're using SALSA with RandomEyes, use the SALSA() command.

If you're using Cheshire, your lines will be animator states, so use the AnimatorPlay() command.

If you're using FacePlus, iClone, or another tool to generate FBX animations, how you use them in cutscene sequences depends on how you set up your avatar. Some developers set up a Humanoid Mecanim rig for the body and leave the face under Legacy animation control. In this case, use the Voice() sequencer command, which plays a legacy animation clip in conjunction with an audio (voiceover) file. Other developers put the face under Mecanim control, too, in which case you'll have an animation layer for the head. Simply use one of the many Mecanim sequencer commands, such as AnimatorPlay() or AnimatorTrigger(), to start the facial animation, and Audio() to start the voiceover audio.

For more details, see How to Add Lipsync.

It's too much work to edit the Sequence field for each entry! How can I automate this?

Use the entrytag keyword in your default sequence. See Using entrytag To Simplify Sequences for more details.

Why doesn't the Fade() sequencer command work in my UFPS project?

If you want to use the Fade() sequencer command in UFPS, add a GUILayer to the player's FPSCamera. The Fade() command uses a GUITexture, so it relies on a GUILayer on the main camera.

How do I pause the sequencer?

See How do I pause the Dialogue System?.


Triggers

Is there any easy way to set up NPC conversation/bark triggers?

Yes! Use the NPC Setup Wizard (Window > Dialogue System > Tools > Wizards > NPC Setup Wizard).

How can I use the Selector component to trigger a conversation with a mouse click?

By default, the Selector component raycasts from the center of the screen to target usable object. To use the mouse position (or a custom position using similar steps):

  1. Change Select At to MousePosition.
  2. Change Use Button to "Fire1" (left button) or "Fire2" (right button).
  3. Set the Layer Mask to include the NPC's layer.
  4. If using an orthographic camera:
    • Set Max Selection Distance far enough that raycasts from the camera's position will hit objects in the scene.
    • Change Distance to GameObject.
  5. Make sure the NPC has a collider and a Usable component.
  6. Set the NPC's Conversation Trigger to OnUse.

The Selector draws a targeting reticle in the center of the screen if Use Default GUI is ticked. If you want to handle the drawing yourself, for example to highlight the targeted NPC or change the mouse cursor image, you can untick this and hook into the SelectedUsableObject and DeselectedUsableObject events.

Why isn't the Proximity Selector working correctly in my 2D project?

Make sure you're not moving 2D rigidbodies manually (e.g., changing transform.position). This breaks Unity's collision detection. Use AddForce or velocity instead.

How do I stop gameplay activity during conversations?

You may want to disable certain gameplay activity during conversations, such as player control and gameplay camera control. To do this, use a dedicated camera for cutscene sequences or disable your gameplay camera controller and/or other controllers during conversations. You can use the Set Enabled On Dialogue Event component to disable these components when On Conversation is triggered and re-enable it when the conversation is done. See Set Enabled On Dialogue Event in Components and on the Player object in the Feature Demo.

Alternatively, you can use Send Message On Dialogue Event to send messages to objects that should exhibit some kind of alternate behaviour during conversations.

See the How to Integrate with Gameplay page for more details and examples.

How can I ensure actors idle at the start of conversations?

If your actors are running when a conversation starts, you may want them to idle. Here are some options:

  1. Set the actors' animation states in the START entry's sequence – for example, use Animation() or AnimatorPlay() or AnimatorFloat(Speed,0).
  2. Use an Animation On Dialogue Event (for Legacy) or Animator State On Dialogue Event (for Mecanim) component set to "On Conversation Start".
  3. Add a Start Sequence On Dialogue Event component set to "On Conversation Start" and use a sequence such as AnimatorFloat(Speed, 0).

Is there a callback, or a way I can find out when a conversation has ended?

Yes. Both participants in the conversation get OnConversationStart messages when the conversation starts and OnConversationEnd messages when the conversation ends. You can also use the "Set Enabled On Dialogue Event" trigger to hide the button during conversations. The Feature Demo uses this trigger to hide the selector and disable player movement during conversations.

Can I trigger another conversation at the end of a conversation?

Yes. Add a Start Conversation On Dialogue Event to one of the participants in the original conversation, and set the trigger to OnConversationEnd. You can't put it on the new participant(s) since only the original participants will receive the OnConversationEnd message.

How can I run arbitrary code during a conversation?

You have several options:

  • Use an existing sequencer command such as SendMessage(), SetActive(), or SetEnabled() – or even use Animation() to change a public property using a legacy animation curve.
  • Write your own sequencer command using the template in Scripts/Templates.
  • Outside of the sequencer system, you can also listen for OnConversationLine messages. (See Script Messages)

How do I run multiple conversations in parallel?

See Simultaneous Conversations.


Quests

How do I make quests spawn killables and make other changes in the game world?

The Dialogue System doesn't provide a built-in spawning system for quests because every game has different needs. It does provide some help, however. Please read the How To Manage Quests section for more information.

Why are there two quest log prefabs for some themes?

The Dialogue System originally shipped with a Unity GUI-based quest log window system. A GUI-independent quest log window system was introduced later. Prefabs built from the new GUI-independent base class end with "Unity <b>GUI</b> Quest Log Window", while the older Unity GUI-only prefabs end with "Unity Quest Log Window".

Can I use the quest tracker HUD without the quest log window?

Yes. Internally, each quest uses a Boolean field named Track. You can add this field manually in the Dialogue Editor or set it using QuestLog.SetQuestTracking(). If it's true and the quest is active, the quest tracker HUD will show the quest. The end of conversations and Increment On Destroy both automatically update the quest tracker. If you update the quest some other way (e.g., kill or collect a target, or advance a quest entry), you can run the code below to update the tracker manually:

DialogueManager.Instance.SendMessage("UpdateTracker");

How do I automatically update quest states outside of conversations?

You can use components such as Increment On Destroy to increment Lua variables when the player kills or collects a quest target. Then use a Condition Observer component to check the status of these variables on a regular frequency. See Using Condition Observers in Quests for more information.


Saving & Loading

Can I add custom data to PersistentDataManager's saved-game data?

Yes. Assign a delegate method to PersistentDataManager.GetCustomSaveData. The method should return a string containing Lua code to run when reloading the game. See the Saving Custom Data (Inventory Table) recipe for a detailed example with code.

How do I save and load using Moodkie's Easy Save 2?

The runtime state of the Dialogue System is stored in Lua tables. To retrieve it as a string, call PersistentDataManager.GetSaveData(). To apply the string back into the Lua tables, call PersistentDataManager.ApplySaveData().

To save using Easy Save 2: (replace key "myFile.txt?tag=dialogueSystem" with your own)

ES2.Save(PersistentDataManager.GetSaveData(), "myFile.txt?tag=dialogueSystem");

To load using Easy Save 2:

PersistentDataManager.ApplySaveData(ES2.Load<string>("myFile.txt?tag=dialogueSystem"));

The Dialogue System Extras page contains an example scene that uses Easy Save 2 and PlayMaker.


Lua

How can I debug my Lua scripts?

On the Dialogue Manager, set the Debug level to Info. This will log Lua commands to the console.

You can also add a Lua Console to your project, for example to the Dialogue Manager object. Select Window > Dialogue System > Component > Lua Console. During play, press ~ + L (tilde plus the "L" key) to bring up the Lua console. Then enter the Lua command to see what result you get. The console will display the result of the Lua command, but it does not trap standard output – so use the command return Actor['Player'].Name instead of print Actor['Player'].Name.

Why are my Lua conditions reporting errors?

When writing Lua conditions, keep these notes in mind:

  • The double equals sign ("==") tests for equality.
  • Logical conditions use and and or, not "&&" and "||".
  • In Lua for the variable name, replace blank space characters and hyphens with underscores, since this is a rule that Chat Mapper enforces. The Dialogue System attempts to automatically recognize and replace blank spaces in as many circumstances as possible, but sometimes it can't when the result would be ambiguous, so try to always manually use underscores in your code: Variable["Menu_Choice"] == "Choice A"
  • Make sure your variable name matches exactly (except for blank spaces/hyphens/underscores as mentioned above). This includes case, since Lua is case-sensitive. That is, "Menu_Choice" is a different variable from "menu_choice".

Why is Lua code near the start of the game raising exception errors?

The Dialogue System delays loading of the master dialogue database until the data is needed by a conversation, bark, sequence, or quest. This avoids potentially long delays during Start() if you have a very large initial database. If you want to run Lua commands that reference the contents of the dialogue database before the Dialogue System has loaded it, first call DialogueManager.PreloadMasterDatabase() to load it into the Lua environment.

How can I get to the code that raised the Lua exception in my Condition or User Script?

By default, the Dialogue System catches any exceptions raised by Lua code in Conditions and Script and simply logs that an exception occurred. If you're calling an external C# function in Lua, you may find it useful to allow the exception to filter up to aid in debugging. To do this, set DialogueManager.AllowLuaExceptions = true.

Is possible to access items from a script?

To check if an item is defined in the Dialogue System, use DialogueLua.DoesTableElementExist(). Example:

bool isSwordDefined = DialogueLua.DoesTableElementExist("Item", "Sword");

To get a field value of an item, use DialogueLua.GetItemField(). Example:

float weight = DialogueLua.GetItemField("Sword", "Weight").AsFloat;

To set a field, use DialogueLua.SetItemField(). Example:

DialogueLua.SetItemField("Sword", "Damage Bonus", 5f);

If you want to iterate through all items, use Lua.Run() to get the Item[] Lua table:

var luaTable = Lua.Run((string.Format("return Item")).AsTable;
float totalWeight = 0;
foreach (var o in luaTable.Keys) {
totalWeight += DialogueLua.GetItemField(o.ToString(), "Weight").AsFloat;
}

Scripting

What notification messages can my scripts listen for?

Your scripts can listen for conversation, sequence, and bark events as detailed in the Script Messages section.

Is possible to call a C# script function from a conversation?

Yes. To call C# in a sequence, add How to Write Custom Sequencer Commands. To call C# in a dialogue entry's Condition or User Script field, register the C# function with Lua. For example, DialogueLua registers this C# function: static public void SetStatus(LuaTable asset1, LuaTable asset2, string status) { ... } using this method: Lua.RegisterFunction("SetStatus", null, typeof(DialogueLua).GetMethod("SetStatus"));

How do I unpack the source code?

The Dialogue System comes with complete C# source code in Scripts/Source Code.unitypackage. See How to Unpack the Source Code for instructions on unpacking it.

When compiling in MonoDevelop, how do I fix Error CS1501: No overload for method X takes Y arguments?

When the Unity editor compiles in the background, it sets up the compiler environment to properly compile its solution. It's generally easier to let Unity do the compiling, but it's often convenient for programmers to build straight in MonoDevelop. However, MonoDevelop defaults to .NET 3.5 syntax, which doesn't handle C# code that uses default parameters (such as the Dialogue System). You can fix this by selecting each assembly (Assembly-CSharp, Assembly-CSharp-Editor, etc.) and then menu item Project > assemblyname > Options > Build/General > Target framework. Set the target framework to Mono/NET 4.0.


Platform-Specific

Why don't sequencer commands work in my iOS, Android, or WebGL builds?

Unity is probably using code stripping. To fix this, locate the file Assets/Dialogue System/Prefabs/iOS/link.xml. Move it to the root Assets folder. Then set Stripping Level to Strip assemblies or Strip ByteCode. The Dialogue System uses the System DLLs, so it is not compatible with Use micro mscorlib.

Can I use code stripping?

Yes! The Dialogue System includes a link.xml file in the Prefabs/Mobile folder (formerly named Prefabs/iOS) that allows you to build Dialogue System projects with Stripping Level set to Strip assemblies or Strip ByteCode. The Dialogue System uses the System DLLs, so it is not compatible with Use micro mscorlib.

My mobile game doesn't use networking. Why does my build ask for networking permissions?

The Dialogue System includes some optional networking utility scripts. If your game doesn't use networking, you can remove the requirement for full network permissions in your builds by deleting these two files:


Third Party FAQs

Note: See the Third Party Support page for information about third party support packages.

How do I integrate with Corgi Engine?

To configure your Corgi player character to pause during conversations, add a Dialogue System Events component. In the Conversation section, add two slots each to the On Conversation Start and On Conversation End events. Assign the Controller and CharacterBehavior components to both events and select the components' enabled properties. In the On Conversation Start event, untick the checkboxes. In the On Conversation End event, tick the checkboxes.

How do I integrate with Platformer Pro?

To configure your Platformer Pro player character to pause during conversations, add a Dialogue System Events component. In the Conversation section, add a slot to the On Conversation Start and On Conversation End events. Assign the Character component to both events and select the InputEnabled property. In the On Conversation Start event, untick the checkbox. In the On Conversation End event, tick the checkbox.

If you also want to set an idle animation, create a script named ControlAnimation.cs containing this:

using UnityEngine;
using PlatformerPro;
public class ControlAnimation : MonoBehaviour {
private SpecialMovement_PlayAnimation specialMovement;
private void Awake() {
specialMovement = GetComponentInChildren<SpecialMovement_PlayAnimation>();
if (specialMovement == null) {
Debug.LogError("No SpecialMovement_PlayAnimation found on " + name, this);
}
}
public void PlayIdleAnimation() {
if (specialMovement != null) specialMovement.Play(AnimationState.IDLE);
}
}
}

Add this script to your character. In the Dialogue System Events component, add another slot to On Conversation Start. Assign ControlAnimation.PlayIdleAnimation.

How do I integrate with Rewired?

Use Unity UI and Rewired's RewiredInputModule for your Dialogue UI.

Set the Dialogue Manager's Cancel keys to KeyCode.None and button names to a blank string. This disables the default input manager check.

Then add a script to the Dialogue Manager that implements the OnConversationLine and OnConversationResponseMenu script messages. In them, send "OnCancelSubtitle" or "OnCancelResponseMenu". The script below uses the same cancel button for both types of cancel:

using UnityEngine;
using Rewired;
public class RewiredToDialogueSystem : MonoBehaviour {
public string cancelButton = "Cancel"; // Define this button in Rewired.
public int playerId = 0; // The Rewired player id.
private Player player;
private string cancelMessage = null;
void Awake() {
player = ReInput.players.GetPlayer(playerId);
}
void OnConversationLine(Subtitle subtitle) {
cancelMessage = "OnCancelSubtitle";
}
void OnConversationResponseMenu(Response[] responses) {
cancelMessage = "OnCancelResponseMenu";
}
void Update () {
if (DialogueManager.IsConversationActive && player.GetButtonDown(cancelButton)) {
SendMessage(cancelMessage);
}
}
}

Miscellaneous

Can I make a Choose Your Own Adventure (CYOA) game?

Yes! A complete CYOA framework powered by the Dialogue System is available on the Pixel Crushers customer download site.

Does the Dialogue System support multiplayer games?

Yes, several multiplayer solutions are supported for player-NPC conversations. (For player-player interaction, use a chat client instead.). Which solutions you use depend on the design of your game. You can use different dialogue databases for different players, or dynamically assign roles in a shared dialogue database at runtime, or conditionally run different dialogue trees (or different branches of the same tree) based on a variety of conditions including quest states, game objects and tags, and even complex Lua expressions. Although this may sound complicated at first because the Dialogue System supports many different methods, each one is actually very simple to use. And you're always welcome to contact us for support if any questions come up.

Every multiplayer game has different needs, and there are many different networking libraries – Photon, SmartFox, Bolt, uNet, etc. – so there's no one-size-fits-all answer. Here's a brief description of a few approaches other developers have implemented.

  • Register custom Lua functions to update variables, quest states, and other Dialogue System data. In addition to using DialogueLua.SetVariable() and QuestLog.SetQuestState() to set them locally, the functions should also send the update to the server. When the player logs back in, the client receives a list of updates to apply locally. To reduce the amount of data to transmit and store, you can record ID numbers rather than quest/variable name strings.
  • Or keep the data in sync across all clients. If one player accepts a quest, all players receive the quest using a custom Lua function that sends the event to the server, which then broadcasts it to all clients.
  • You can also override your dialogue UI (such as UnityUIDialogueUI) to present a synchronized, shared dialogue UI to all players. Players could take turns choosing responses.
  • Or perform timed checkpoint saves. Grab the entire saved game string with PersistentDataManager.GetSaveData() and send it back to the server where it's stored as a string in, for example a MySQL database.
  • If you know you'll only be updating Dialogue System data inside conversations, you add simply add a script with an OnConversationEnd method that runs a checkpoint save.

How do I pause the Dialogue System?

To pause the Dialogue System, call DialogueManager.Pause(). To unpause, call DialogueManager.Unpause(). This will pause conversations, sequences, and barks. The sequencer commands AudioWait() and Voice() will also pause. Other than this, it won't pause AudioSource, Animation, or Animator components; you must do this on your own. Your scripts can listen for OnDialogueSystemPause messages to pause these components. (See Other Messages for more details.)

If DialogueTime is set to Realtime (the default), pausing will only affect the Dialogue System. If DialogueTime is set to Gameplay, pausing will set Time.timeScale to 0, and unpausing will set it to 1.


Troubleshooting

Why are the NPCs' names and other text in the example scenes just a string of random numbers?

If you're using Unity 5.x and you project uses Force Text or Force Binary serialization, please change it to Mixed mode before importing the Dialogue System. You can change it back afterward. Several example scenes were built in Unity 4 to maintain compatibility with Unity 4 developers. Unity 5 sometimes has difficulty importing scenes made in Unity 4 due to a 32-bit/64-bit compatibility issue.

How can I debug what's going on in the Dialogue System?

First, set the Dialogue Manager's Debug Level to Info. This will log almost everything that's happening under the hood.

Second, add a Lua Console component to your Dialogue Manager: Window > Dialogue System > Components > Lua Console. During gameplay, press ~ + L (tilde plus the "L" key) to open the Lua Console. Then enter any Lua commands to set or retrieve values from the Lua environment.

Why can't I see subtitles?

First, make sure the appropriate subtitles checkbox (NPCSubtitles During Line, NPCSubtitles During Response, or PC Subtitles During Line) is ticked in your Dialogue Manager's Dialogue Manager Display Settings.

If this is correct, then on your UI prefab make sure the subtitle GUI controls are assigned properly to the DialogueUI component, and that the controls are positioned to be visible on the screen. If you're using the Unity Dialogue UI system, verify that the Scaled Rect is set the way you want; the dimensions have different meanings depending on whether you're using Pixel or Normalized scale.

When using multiple databases, why do conversations use entries from another conversation?

Conversations in two databases probably have the same ID number. Use the Unique ID Tool to make IDs unique. For more information, see How To Use Multiple Dialogue Databases.

When updating, why does Unity fails with "Moving File Failed"?

This error happens when the OS temporarily locks a file, preventing Unity from moving it into its final destination in your project.

  • If the error is being reported on a DLL, your antivirus software is probably trying to scan it at the same time that it's being moved into the project. Try temporarily disabling your antivirus scanner.
  • If your project is in a Dropbox folder (or similar cloud-syncing service), temporarily disable synchronization.
  • If you're using Windows, sometimes the indexing service causes the issue. In this case, right-click on your project folder and select Properties > General > Advanced. Untick "Allow files in this folder to have contents indexed...".
  • If your project is deeply nested and/or in really long folder names, you could be hitting the filename length limit. Try moving your project into a shorter path.

Why does my project fail to build using Unity Cloud?

By default, Git ignores DLL files and doesn't upload them to Unity Cloud. Enable DLL versioning by removing .dll from your project's .gitignore file and your global gitignore file ([user].gitignore_global in Windows, ~/.gitignore_global in Mac and Linux).

I'm stuck! Can I send you a reproduction project that demonstrates my issue?

Absolutely! We're here to help. Use these steps:

  1. Zip up your project's Assets and ProjectSettings folders into a zip file.
  2. If your project is large, you may want to use the Repro Wizard package detailed here make a stripped down version:
  3. Send the project (or a download link) to support (at) pixelcrushers.com along with the steps required to produce the issue, and let us know what version of Unity to use.

<< Recipes | Release Notes >>

PixelCrushers.DialogueSystem.Articy.EntityCategory.Player
PixelCrushers.DialogueSystem
Definition: ArticyConverterWindow.cs:8
PixelCrushers
Definition: ArticyConverterWindow.cs:8