Search Unity

[RELEASED] Dialogue System for Unity - easy conversations, quests, and more!

Discussion in 'Assets and Asset Store' started by TonyLi, Oct 12, 2013.

  1. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Tony,

    is PixelCrusher's website down? We haven't been able to access the documentation for a couple of days.

    Thanks!
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @barjed - It went down today at 6:57 EST (about 3 hours ago) after a couple days of slow performance. Bluehost (the service provider) is working on restoring service. In the meantime, you can download an offline copy of the documentation here:

    Offline Documentation

    Don't unzip it into your project's Assets folder. It contains .js Javascript files that would confuse Unity.

    I'll post again here as soon as I get a status update from Bluehost.
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Looks like the website is up again. I'll continue to work with the service provider if it's running slowly.
     
  4. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Many, many thanks for this. I won't have time to test it this weekend unfortunately, but in a few weeks I should have a little time off and I'll be able to get this nailed down.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Sounds good! If any questions come up (since I may have glossed over a point or two), just let me know!
     
  6. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Great, thank you very much!
     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Ultra Quick Start and PlayMaker Integration Tutorials

    New tutorials are online:

    Ultra Quick Start


    PlayMaker Integration


    You can access all tutorials on the Tutorials page!
     
    hopeful and BackwoodsGaming like this.
  8. ProtoJazz

    ProtoJazz

    Joined:
    Nov 27, 2012
    Posts:
    19
    Im considering using this for a project, but Im wondering if I would be able to change the dialog based on code. For example a dialog might have an extra option if the player has an item in the inventory, or a guy might walk up and say "Hey, nice ______" where the blank is filled with a random inventory item. Is this posible?
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @ProtoJazz - Sure, that's right down the Dialogue System's alley! Every dialogue option can have a set of conditions. The dialogue option will only be shown if the conditions are true. Under the hood, conditions are expressed in Lua. For most purposes, you can use the point-and-click Lua wizard so you don't need to type any Lua code. You can also register your own C# code with Lua. The third party integrations such as for Inventory Pro and S-Inventory do this, letting you show a dialogue option conditionally based on whether the player has an item in Inventory Pro or S-Inventory (or Adventure Creator, or UFPS, or RPG Kit, etc.).

    You can also use special markup tags in your dialogue text. The [lua] markup tag inserts the result of a Lua expression (e.g., your C# code) into the text. You could write a C# function that returns the name of random inventory item.

    This may be off topic, but you can also create entire conversations in code and add them at runtime using DialogueManager.AddDatabase(), so you're not limited to the conversation trees that you've created at design time. More than one project imports player-written and/or DLC content at runtime this way. You can also import conversations from XML at runtime.
     
    Last edited: Dec 1, 2015
  10. cewadmin

    cewadmin

    Joined:
    Jun 10, 2015
    Posts:
    1
    Wonderful. Expect a sale when the next ludum Dare starts
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Great! The Dialogue System is a pretty big asset to learn during a Ludum Dare, although others have done it. You may want to pick it up a few days beforehand to familiarize yourself with it first.
     
  12. ProtoJazz

    ProtoJazz

    Joined:
    Nov 27, 2012
    Posts:
    19
    I usually would, but this LD takes place the weekend between leaving a job and starting a new one. So I wont have much time until friday night
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    No worries; I'll be around, so don't hesitate to post here or email me directly at tony (at) pixelcrushers.com if you get stuck on anything.
     
  14. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Actor Subtitle Color Component

    Several people have asked how to show every actor's subtitles in a different color. You can set individual lines using rich text codes or [em#] emphasis tags. But the easiest way to set a color across the board for all of an actor's lines is to use the Actor Subtitle Color component. This is an add-on component that you can download from the UIs section of the Dialogue System Extras page.


    Also, patch 1.5.7a-2015-12-01 is available on the customer download site. (PM me your Asset Store invoice number if you'd like access.) The patch contains:
    • Updated: Compatibility with Unity 5.3.0 beta.
    • Unity UI: Added animated portrait support; fixed an issue where the alert panel was briefly visible at start of scene.
    • Improved: Selector component no longer requires an EventSystem.
    • articy:draft Converter: Fixed unhandled exception trying to import textures not in project.
    • Chat Mapper Converter: Fixed bug that wasn’t removing ‘Resources’ from audio file resource paths.
    • RPG Kit: RPG Kit 3.1.1 compatible; added Update Quest Tracker action; Saves data (character specific); added RPG Kit Store Trigger No Out Of Range Message component.
    • Master Audio: Updated for latest version of Master Audio.
     
  15. Darkkingdom

    Darkkingdom

    Joined:
    Sep 2, 2014
    Posts:
    81
    Hey Tony :)

    Following Situation:
    I'm using Rewired instead of the Unity InputManager.
    That means I can't use the "Cancel" or "Cancel Conversation" field in the inspector.
    Because Dialogue system searching the buttonsname in the InputManager.
    Sooooo is there a possibility to script the input for the Cancel and Cancel Conversation buttons :)?

    Thank you very much^^
     
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @Darkkingdom - Yes, to script Cancel:
    Code (csharp):
    1. DialogueManager.Instance.SendMessage("OnCancelSubtitle");
    To script Cancel Conversation:
    Code (csharp):
    1. DialogueManager.Instance.SendMessage("OnCancelResponseMenu");
    So your script might look something like this:
    Code (csharp):
    1. using UnityEngine;
    2. using PixelCrushers.DialogueSystem;
    3. using Rewired;
    4.  
    5. public class RewiredCancelDialogue : MonoBehaviour {
    6.  
    7.     bool isResponseMenuActive = false;
    8.  
    9.     void OnConversationLine(Subtitle subtitle) {
    10.         isResponseMenuActive = false;
    11.     }
    12.  
    13.     void OnConversationResponseMenu(Response[] responses) {
    14.         isResponseMenuActive = true;
    15.     }
    16.  
    17.     void Update() {
    18.         if (DialogueManager.IsConversationActive) {
    19.             var player = ReInput.players.GetPlayer(0);
    20.             if (isResponseMenuActive) {
    21.                 if (player.GetButtonDown("CancelConversation")) {
    22.                     DialogueManager.Instance.SendMessage("OnCancelResponseMenu");
    23.                 }
    24.             } else {
    25.                 if (player.GetButtonDown("Cancel")) {
    26.                     DialogueManager.Instance.SendMessage("OnCancelSubtitle");
    27.                 }
    28.             }
    29.     }
    30. }
    The Update() above is sloppy. I kept it short rather than efficient. You'll want to clean it up in your script.
     
    hopeful and Darkkingdom like this.
  17. Darkkingdom

    Darkkingdom

    Joined:
    Sep 2, 2014
    Posts:
    81
    WOW I expected a short hint, but you wrote me the whole script xD
    Things like these makes you to the best asset creator from all :)
    Keep that up!

    Thank you so much^^
     
    hopeful likes this.
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    My pleasure!
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Pixel Crushers Website Downtime Tuesday 12/8/2015 9:30 AM MST

    The pixelcrushers.com website will be down tomorrow from 09:30 AM - 10:00 AM MST for maintenance. If you can't connect then, please try again after a few minutes. Thanks!
     
  20. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    Hi TonyLi,

    I'm trying to implement a linear conversation using ngui bark ui.

    1. how do I turn off the previous displayed text i.e. when player speaks the npc dialogues should not be displayed and vice versa.

    2. What is the purpose of assigning the continue buttons for player and npc in the 'ngui dialogue bark ui' script when the continue button already sends an OnContiune message?

    3. continued from above, On assigning the continue button to player and npc in the 'ngui dialogue bark ui' script(same button for both ), the button gets disabled in the hierarchy.

    As a temporary workaround, I have unassigned play and npc continue buttons,
    and setup an OnContinue method in the nguibarkui script which invokes the hide method.
    I send OnContinue from the continue button when clicked.(but i have to manually assign the message receivers)
     
    Last edited: Dec 8, 2015
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @vivalavida - Unassign the UI elements from Dialogue > Response Menu > Subtitle Reminder. Other than that, make sure the UI elements are hooked up similarly to the example scenes/prefabs. It sounds like you're using bark UIs; the setup will be similar, except the lines will be directed to the participants' bark UIs. If you get stuck, please feel free to send a screenshot or example scene to tony (at) pixelcrushers.com. I'll be happy to take a look.

    When a continue button is assigned to the script, the script knows about the button and can show or hide it according to the Dialogue Manager's Continue Button mode. If it's not assigned, then the script will ignore it. However, the button itself can still send 'OnContinue' to progress the conversation.

    This is because the Dialogue Manager's Continue Button mode defaults to Never. You can change it to Always if you want to always show the continue button, or one of the other settings to show the continue button only in certain situations.
     
  22. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    The Lua environment needs one frame to set itself up first. (This detail is tucked away in the documentation and really easy to miss.) Try this:

    Code (CSharp):
    1. IEnumerator Start ()
    2. {
    3.     yield return null; // Let the Lua environment set itself up first.
    4.     DialogueLua.SetVariable("PlayerName", "test");
    5.     DialogueLua.SetActorField ("Player", "PlayerName", "test");
    6.     DialogueLua.SetActorField ("Player", "Name", "test2");
    7. }
     
    alexhapki and hopeful like this.
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Dialogue System Compatibility with Unity 5.3

    If you're using the Dialogue System for Unity 1.5.7a or earlier and want to update to Unity 5.3:
    1. Back up your project beforehand. This is always a good general practice. If a new version of Unity has a breaking bug with your project, this makes it easy to go back to an earlier version of Unity.

    2. Download the Dialogue System patch on the Pixel Crushers customer download page. This patch adds support for Unity 5.3, which introduced some API changes. If you need access, please PM me your Asset Store invoice number.

    3. Unity 5.3 changed the way packages are imported. Review the import window carefully before giving it the go-ahead. In particular, if you've selected "Reinstall," Unity will first delete the files in the Gizmos and Dialogue System folders. If you or another plugin has added files to these folders, make sure you don't delete them accidentally.
     
  24. alexhapki

    alexhapki

    Joined:
    May 8, 2015
    Posts:
    32
    Hi Tony,

    Thanks for the fast answer, and also because it was helpful. Setting variables from scripting at run time works now marvellous well. Thanks a million.
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    My pleasure!
     
  26. blaher

    blaher

    Joined:
    Oct 21, 2013
    Posts:
    80
    <wishful thinking most likely> I know this is an issue for all asset store plugins, but for Dialogue System specifically.... is there a forum or other place where posts here are organized into threads instead of one massive 44 page mess? I would love to browse through topics/questions but one big ol zillion page single thread is a nightmare to use.
     
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Wish granted: http://pixelcrushers.com/phpbb/ ;)
     
  28. blaher

    blaher

    Joined:
    Oct 21, 2013
    Posts:
    80
    Awesome that you have a forum, but it looks like it is separate from this massive thread. Seems like some gems are in here that are not in the forum (likely the other way too).
     
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    You are correct. Unfortunately there isn't a good way to link them together. If you're looking for anything in particular, please post here or on the Pixel Crushers forum. I'll be happy to reply with links to relevant forum posts or provide a new response if needed. No need to spin your wheels if you get stuck on anything; I'm here to help. :)
     
  30. Candescence

    Candescence

    Joined:
    Aug 26, 2014
    Posts:
    107
    Just a quick question (since I can't find anything on this), how do you do multiple portraits per character? It seems that's only partially supported.
     
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @Candescence - In the Dialogue Editor, click the "+" button in the Portraits section:



    Add as many portraits as you want. More details are here.

    When you want to show a different portrait image for a specific dialogue entry, add a [pic=#] tag to the Dialogue Text.

    If you want to permanently change the default portrait image for an actor, use the SetPortrait() sequencer command.


    If you want to use animated spritesheets for portraits in Unity UI, the latest patch on the customer download page supports it, as documented here. This will also be in the next release of the Dialogue System.
     
  32. Candescence

    Candescence

    Joined:
    Aug 26, 2014
    Posts:
    107
    Ah, the [pic=#] tag was what I needed, thanks. Seems I missed that.
     
  33. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    Hi again,
    I've created my own dialogue label template using ngui these are in the form of a speech bubble.. I wish that they disappear in an animated fashion before the next dialogue appears.
    How should i go about doing this?
     
  34. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    Hi,
    another question,
    How should I specify a template(UILabel, UIPanel) for the 'press Space to interact' message which comes with the Proximity Selector.
     
  35. Mr-Nixon

    Mr-Nixon

    Joined:
    Mar 30, 2013
    Posts:
    140
    Hi,

    Today while I work on a dialog (text entering) suddenly all database with dialogues, avatars, variables, quests, was wiped out completely with all work done... there was no message - nothing....

    Is there any way to restore data and prevent further unexpected wipes?
     
  36. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @vivalavida - Unlike the Unity UI scripts, the NGUI scripts do not use animation for this. They use NGUITools.SetActive. You will have to customize one method. Edit Third Party Support/NGUI/Scripts/NGUI Dialogue UI/NGUI Dialogue Controls/NGUIDialogueUIControls.cs. It contains one method: SetControlActive. I suggest you change this to look for an Animation or Animator component on the control. If you find one, run a coroutine that plays the animation and waits until it's done. Then call NGUTools.SetActive to hide it.

    The main NGUI Support example scene (Feature Demo Using NGUI) contains an example. Here are the steps:
    1. Create a template similar to UI Root (2D) Barks and Selector/Canvas/Selector Anchor. You may find it easiest to simply copy this into your scene and customize the appearance.
    2. Add an NGUI Selector Display component to your player, and hook up the references to the UILabels and UIPanel.
    Hi @Mr.Nixon - Yikes! That's not good. I'm really sorry to hear that. Can you recall if anything special was happening at the time, such as importing another plugin, or switching serialization mode, or syncing your project from a repository while it was open? Dialogue databases are plain old ScriptableObjects, like Animator Controllers, GUI Skins, etc., so there's nothing special about them that would make this happen. If you want to try to get to the bottom of it, I'm willing to work with you however you want.

    For the future, I recommend one or more of these if you don't already do them:
    1. Make regular backups of your project.
    2. Use version control.
    3. Export your database to Chat Mapper XML format every once in a while.
    You don't need Chat Mapper to export to Chat Mapper XML format. This just gives you a text-based copy that you can always import back into Unity. It might be overkill, but then again it might give you extra peace of mind. Again, please let me know if you want to investigate the issue and if there's anything I can help with.
     
    vivalavida and hopeful like this.
  37. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    432
    I'm pretty sure this is a noobie question but...
    is there a simple solution to check a condition in a conversation node ?
    Like "do you know how to cockwheel?!"
    - yes" (if the cockwheel skill is unlocked, by boolean or an array value)
    -nope !" (if not unlocked)

    Is there a way to check it with a simple C#script or must we really learn this lua thing ?
    thx !
     
  38. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @RemDust - Yes. Here are two ways. You can choose the one you prefer.

    1. Set a Dialogue System variable in an OnConverstionStart method that's in a script on your player:

    Code (csharp):
    1. using UnityEngine;
    2. using PixelCrushers.DialogueSystem;
    3.  
    4. public class SkillsToDialogueSystem : MonoBehaviour {
    5.  
    6.     public void OnConversationStart(Transform actor) {
    7.         DialogueLua.SetVariable("CockwheelSkill", SkillSystem.IsUnlocked("Cockwheel")); // Example.
    8.     }
    9. }
    Define the CockwheelSkill variable in your dialogue database. Then in your dialogue entry check its value:




    2. Or, register your C# function(s) with Lua and use them in the Conditions and Script fields.

    Code (csharp):
    1. using UnityEngine;
    2. using PixelCrushers.DialogueSystem;
    3.  
    4. public class MyLuaFunctions : MonoBehaviour {
    5.  
    6.     void OnEnable() {
    7.         Lua.RegisterFunction("IsSkillUnlocked", this, typeof(MyLuaFunctions).GetMethod("IsSkillUnlocked"));
    8.     }
    9.  
    10.     void OnDisable() {
    11.         Lua.UnregisterFunction("IsSkillUnlocked");
    12.     }
    13.  
    14.     public bool IsSkillUnlocked(string skillName) {
    15.         return SkillSystem.IsUnlocked(skillName);
    16.     }
    17. }
    And then call that C# function:

     
    RemDust, BackwoodsGaming and hopeful like this.
  39. Mr-Nixon

    Mr-Nixon

    Joined:
    Mar 30, 2013
    Posts:
    140
    Hi Tony,

    I know, it's my fault I didn't save often. Np. It's a one more lesson for me :)

    Just feel like to share so that polish the system. So it was completely cleat project without any plugins: just dialogue system. As usual I switched to variable list in it to check the default state of a variable. Suddenly there were no variables. Puzzled, I switched back to the dialogues and there were no dialogues despite I've been working on them a moment ago...

    Anyway, will make backups and keep an eye on that possible bug.
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    What version of Unity are you using? Again, I'm sorry you lost data. I'll scour the code for any possible culprit.
     
  41. Mr-Nixon

    Mr-Nixon

    Joined:
    Mar 30, 2013
    Posts:
    140
    The latest 4 Pro.

    I also noticed that if you delete or modify text in dialog text field it it can't be restored (or reversed back) by CTRL+Z.
     
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Thanks. I'll look into this.

    I'll add this in the next version (coming out soon).
     
  43. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    Thanks a lot @TonyLi , you've been really helpful.

    Sadly I'll have some more doubts coming your way.

    For now, I want to display an alert message and force the player to press the continue button and even disable his movement till he does so.

    I thought of using a bark since all the functionality is already in there, but i cant get it to display in the alert Panel.
    I'm using NGUI.
    Thanks.
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @vivalavida - I'm glad to help! You could use an alert message for this. I'll describe how to do this with the provided NGUI Support scripts. You can of course change how they work or even provide your own scripts instead.

    1. Show your alert using a script similar to this:

    Code (csharp):
    1. public class PausedAlert : MonoBehaviour {
    2.  
    3.     public void ShowPausedAlert(string message) {
    4.         DialogueManager.ShowAlert(message, Mathf.Infinity);
    5.         // <Your code here to disable player movement>
    6.     }
    7.  
    8.     public void OnCloseAlertPanel() {
    9.         // <Your code here to re-enable player movement>
    10.     }
    11. }
    2. In your dialogue UI, add or enable the alert panel's continue button. Make sure it's assigned to the Continue Button field in your dialogue UI component. I believe there's an example scene with a continue button that you can look at for a model. Add another event handler to the continue button that calls PausedAlert.OnCloseAlertPanel.


    If you want to also show alert messages without the continue button sometimes, you could change the script to this:

    Code (csharp):
    1. public class PausedAlert : MonoBehaviour {
    2.  
    3.     public UIButton alertContinueButton; //<-- Assign your button here.
    4.  
    5.     public void Start() {
    6.         NGUITools.SetActive(alertContinueButton.gameObject, false);
    7.     }
    8.  
    9.     public void ShowPausedAlert(string message) {
    10.         DialogueManager.ShowAlert(message, Mathf.Infinity);
    11.         NGUITools.SetActive(alertContinueButton.gameObject, true);
    12.         // <Your code here to disable player movement>
    13.     }
    14.  
    15.     public void OnCloseAlertPanel() {
    16.         NGUITools.SetActive(alertContinueButton.gameObject, false);
    17.         // <Your code here to re-enable player movement>
    18.     }
    19. }
     
    vivalavida likes this.
  45. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    Thanks.
    Next, I can't get Selector follow target to work with NGUI and would it be possible to set a custom position per target if needed.
    right now, the ngui selector is displayed in the default position as well as a default Gui text appears over the targets head.

    Also,how do i make the selector turn off when the conversation is triggered?

    Again, thanks a lot.
     
    Last edited: Dec 16, 2015
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @vivalavida - SelectorFollowTarget currently only supports legacy Unity GUI. I'll add support for NGUI in the next release, which is coming very soon.

    I recommend using Set Component Enabled On Dialogue Event, as described in How to Set Up the Player. For an example, look at the Player in the NGUI support test scene. It disables player movement and the selector during conversations.
     
    vivalavida likes this.
  47. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    The Dialogue System for Unity got a really nice mention in Epic Industries' Arrival in Hell dev blog. (Thanks, Matt Shaile!) You can follow development of this modern remake of the critically acclaimed game here: Arrival in Hell.

    And here are some more great games made with the Dialogue System:

     
    EDarkness and vivalavida like this.
  48. Temuzhin

    Temuzhin

    Joined:
    Apr 9, 2015
    Posts:
    23
    Hello,

    How can I let the player choose between dialog options with key numbers instead of mouse input?

    Thanks.
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @Temuzhin - If you're using Unity UI, assign a UI Button Key Trigger component to each response button. An easy way to do this automatically is to use the free "Numbered Responses" script on the Dialogue System Extras page. It's the second download in the "UIs" section.
     
  50. Temuzhin

    Temuzhin

    Joined:
    Apr 9, 2015
    Posts:
    23
    Hello,

    I have not been able to use the NumberedResponseDialogueUI.cs because it doesn't accept "GUIButton", but only "Unity UI Response Button".

    Thanks.