Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Our response to Improbable’s blog post (and why you can keep working on your SpatialOS game). Read more here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

[WIP] Dialog System

Discussion in 'Works In Progress' started by macorig, Sep 16, 2012.

  1. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Hi!

    I am currently learning scripting in Unity and for my first big project I have started working on a dialog system, which I plan to expand on from project to project, always improving it a bit.
    The idea was to create a system that would allow easy dialog setup using a node-based custom editor. What I currently ended up with is a bit of a mess in some areas and I hope to streamline it as much as I can, but other than that I'm actually quite happy with the way it turned out so far, especially since it already contains most of the features I wanted it to have.

    I'm not really an experienced programmer, which is why I would be really glad if I could maybe get some pointers or tips on what could have been done better, more elegant or performant.


    Webplayer
    (press left mouse button or 'e' to start the dialog, to select an answer option use W/S or click on it)

    Example Project

    To edit a dialog click on the "Edit" button of the target's Dialog component in the inspector. You can navigate by holding down the middle mouse button or using the preview in the upper right corner (drag). To create a node choose a node type from the popup in the top left corner and then click "Create Node" - the new node will show up in the work area (but it might be hidden by other nodes). To create a connection between two nodes click "out/in" on two different nodes. Do the same for an already existing connection to delete it. To delete a node press the "X" button and uncheck the checkbox to disable one.
    The text field next to the "Save" button defines the dialog's start node, just enter a node's ID (the number in the node window's title).

    If you want to apply changes you've made to the dialog you have to press "Save" and overwrite the XML-file you want to change.


    To create a dialog you basically have the following types of nodes:

    • Text: A common text box with a target-field that basically specifies who is supposed to say it.
    • Choice: This will show a choice with different answer options
    • Answer: The different answer options that belong to a choice node. You can type in the order in which it's supposed to be shown as well as the answer's title.
    • Switch: The switch will check a variable from a static hashtable according to its child case nodes
    • Case: A case node takes an order variable (similiar to that of an answer node) as well as a method ("==", ">", ...) and a value.
    • Variable: This nodes allows you to define new varaibles in the static hashtable or add to/subtract from existing ones, if they are integers. Type in the variable (actually the 'key'), choose a method ("=", "+", "-") and enter a value. Currently supports numbers only.
    • Script: This node allows you to call a function (via SendMessage). The popup allows you to choose the target game object of the SendMessage-function and the two text fields take the function name and a string parameter. This might also be used to call something like a "SetAnimation" function, if set up.
    • Pass: A pass node doesn't do anything and just redirects to the following nodes. This is useful for creating 'bottlenecks' when using a lot of alternative text nodes in a branching structure.

    If a node has more than one following node it will choose one by random (except for choice/switch nodes), which makes it very easy to create alts. In the example above I'm using a switch and variable node to check if the player has talked to this character before, giving a different greeting, if he has.

    If you think this dialog system might be useful for a game project of yours (both, non-commercial and commercial) just take a look at the scripts and see if you can work with them. Feel free to use and modify anything of it you like.

    Feedback and criticism welcome!


    Special thanks to spartan for helping with number of fixes and improvements to both code and workflow!
     

    Attached Files:

    Last edited: Jun 16, 2013
  2. DigitalX

    DigitalX

    Joined:
    Aug 26, 2012
    Posts:
    10
    Hey the demo looks great. Is this free to use for commercial use etc ?
     
    Last edited: Sep 16, 2012
  3. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,554
    Hey that editor window looks really neat. I'd suggest that you don't need to have a node for a choice ... if a text or answer node has more than one arc flowing out of it it should be a choice by definition.

    EDIT: Variables and functions might better be associated with arcs too (at least visually), again to simplify the view.
     
  4. DigitalX

    DigitalX

    Joined:
    Aug 26, 2012
    Posts:
    10
    Thats what I was thinking too.
     
  5. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    @DigitalX and JohnnyA

    Thanks!

    @DigitalX

    I have yet to make a final decision about wether or not I want to allow commercial use, but non-commercial is definitely fine. I think I'll give an update on that soon. But for now I'd recommend considering other free/cheap solutions.

    @JohnnyA

    The way it works now you can add answer nodes only via clicking the "Add" button (which replaces the "Out" button) on a choice node. This way you can't accidentally mix text and answer nodes as a choice's out and at the same time you can have a text node with multiple outs for random 'routing'.
    However I'll definitely look into this and see if I can change this logic to have a more 'economic' node use.
     
  6. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,554
    :) PS I'm creating an adventure game kit at the moment, and wanted to add a dialog system. Whats the license on your code? Although I'd be implementing the dialog itself quite differently the editor looks great and I'd love to borrow some code ;) I'd be happy to organise something commercial, send me a PM.
     
  7. DigitalX

    DigitalX

    Joined:
    Aug 26, 2012
    Posts:
    10
    Please check out the new pm I sent you
     
  8. DigitalX

    DigitalX

    Joined:
    Aug 26, 2012
    Posts:
    10
    You still didnt read my pm Macorig
     
  9. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    @DigitalX
    Slowly, slowly - when you made your post before that last one I had already gone to bed, hehe (that was 6:22 AM over here).

    As I've just PM'ed you, I am going to allow its use for commercial game projects.
     
  10. ChadM

    ChadM

    Joined:
    Jul 3, 2012
    Posts:
    73
    Hey could you PM me with the source? I'd be interested in something like this big time!
     
  11. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Just uploaded an updated version.

    • Instead of a SelectionGrid I now use a custom class to display the answer options of a choice node. It should now support options containing multiple lines of texts without problems
    • You can now type something like "[key]" to insert variables into a node's text. If such an entry exists in the static hashtable it will be inserted into the text (i.e. write "You have [money] pieces of gold.")
    • Small other fixes and some code cleaning

    ... somewhat unrelated to the dialog system, I did a small practice for hand painted styled textures and used it to graphically update the example project / webplayer.


    @ChadM

    Just download the example project and get the source from there.
     
  12. SilverHelmStudios

    SilverHelmStudios

    Joined:
    Aug 21, 2010
    Posts:
    128
    Hi Micorig,

    This is a very great product you have here. Can you please PM me in regards to a commercial license as well? My company was just about to start working on our system when I came across this. I think it will shave a major chunk of production time off of what we were planning already. Thanks in advance.
     
  13. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Didn't find a lot of time to work on this lately, but I've just uploaded an updated version.
    • new text mark-up options to define optional text and alts
    • variable nodes now differentiate between "local" and "global" variables
    • code for ingame node logic is a lot cleaner now
    • small other fixes and code cleaning

    I've continued experimenting with regular expressions and I've come up with a syntax to define optional text and alts using "{", "}" and "|" within the text you want to be displayed:

    {optional}
    Text between curly brackets is optional and will be displayed with a 50:50 chance​

    {option1|option2|option2}
    Text written like this will choose one of the different options at random​

    You can also compine both syntaxes to get even more randomized results. You can mark up any text like this, as long as it doesn't contain any of the three characters "{", "}", "|", so you can also insert variables ("[variable]").

    The updated web player has a new character called Joe, whose dialog basically consists of three text nodes, two of which are:

    When using nodes to define dialog variables you can now set them to be either "local" or "global". When checking for a variable using a switch node or getting one to insert it into dialog text it will always look for a fitting entry in the "local" hashtable first and go on to the global one if it couldn't find one.
    Also, a variable "counter" is now a local dialog variable entry by default, counting the times the dialog has been gone through.
     
  14. castor

    castor

    Joined:
    Sep 9, 2012
    Posts:
    37
    Do you have a webpage dedicated to this? If I want to look at the Documentation is it only written in this thread?

    Congrats on the great product!
     
  15. castor

    castor

    Joined:
    Sep 9, 2012
    Posts:
    37
    Also how you would go about verifying if the player has already gone through a certain question branch so that it doesn't show again?
     
  16. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    This looks slick as hell, bookmarked the thread, i cant help but think this has to be useful for so many things, not just dialogue!
     
  17. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Thanks!

    Once I feel like this small project is anywhere near completion I certainly will dedicate a website to it and create a detailed documentation, but as of now this thread is all there is.
    Unfortunately I haven't been able to work on it lately due to a lack of spare time and other projects, though.

    @castor
    The easiest solution would probably be to code some sort of "has been activated"-flag into the answer nodes to determine wether they show up again or not. Alternatively you could maybe use a dialog variable you store in the dailog system's global variable-hashtable to ease serialization. I'll definitely look into this for the next update!
     
  18. Gurc

    Gurc

    Joined:
    Jul 9, 2012
    Posts:
    43
    I know time has passed but I must say : This is wondeful. Exactly what I had in mind but unable to implement.
    I had the UnityEditor reference error. However with the latest Unity version it is now cleared.
     
    Last edited: Apr 12, 2013
  19. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Hi there! I hope you find it helpful.
    I've actually kept working on this, but wasn't able to put any time into it lately. Might very well take a couple of months before I feel confident enough to upload an updated version. One new feature I've been working on, however, is a function to load dialogs from XML-files as well as save them to that format. That should make for easy localization and text editing options.
    Sooner or later I also really should completely rework the dialog editor, so it's a bit less of a mess.
     
  20. sibelesse

    sibelesse

    Joined:
    Apr 18, 2013
    Posts:
    1
    hi macorig,your script is very usefull but there is no audio enter.I have try to add audio channel but I couldnt.can you help me to do it thanks.
     
  21. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Well, you're not the first to ask for an audio feature - unfortunately, I don't think I'll be able to come up with something for that any time soon, as I really want to get the non-audio basics done and working properly, first. Sorry.
     
  22. spartan

    spartan

    Joined:
    Mar 10, 2010
    Posts:
    173
    @macorig, sent you a PM.
     
  23. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Thanks to spartan who did a couple of fixes and workflow improvements to the code of my latest version featuring experimental XML load/save-functionality I can now feel safe to upload the updated version for people to try and check out.

    Take a look at the new version in the first post or click right here. (Webplayer)

    Changes:
    • Load from/save dialogs to XML-files
    • Variables currently support numbers only and you can now check wether a variable hasn't been defined yet (spartan)
    • Default character names and file paths (spartan)
    • View/edit character name in the editor window (spartan)
    • Dialog nodes are now color-coded to improve clarity (spartan)
    • ...

    To apply a dialog to a new game object, simply add the Dialog component and press 'Edit' - a blank XML dialog-file will be created at the specified path.
    To save your dialog click "Save" in the dialog editor and overwrite the dialog you want to update or save it as a new file.

    Until now I've had all dialog XML-files saved under Assets/Dialogs but have decided to try to load them via Resources.Load() to avoid problems with webplayer builds, so by default they will now be saved to Assets/Resources/Dialogs/ and have to be located somerwhere in Assets/Resources.
    I however ran into a couple of problems with this and will see if I can come up with a better solution or fix this one up a bit...
     
  24. MadDogBrown

    MadDogBrown

    Joined:
    Sep 24, 2013
    Posts:
    1
    hi macorig,

    this dialog is great. while I;m not a coder i have managed to get my head around most of this system, but the only thing i can't get my head is how to end a conversation and go back to contrling character to speak to another character. Any help from you or anyone on this forum would be much appreciated.

    thanks
     
  25. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Hi MadDogBrown!

    The DialogController has an activeDialog-variable, which is either null or contains the currently active Dialog-Component you want to display. To end a conversation use the Dialog-Components Exit()-Function (if there's no next node to display it will exit automatically). The Dialog-Component assumes that there's a GameObject with the tag "Player", that has the DialogController attached to it and when you call Exit() it will set its DialogController's activeDialog to null. With no Dialog to display or control the DialogController falls back to managing targets, which in my example project currently works with a simple raycast.

    In the DialogController you basically have this structure in the Update()-function:

    Code (csharp):
    1.  
    2. if(activeDialog) {
    3.   //What to do when there's an active Dialog
    4.   //--> Manage dialog controls
    5. } else if(Input.GetButtonUp("Fire1")  target  target.GetComponent(Dialog)) {
    6.   //There is no active Dialog and the player presses the mouse button
    7.   //and there is a target that also has a Dialog-Component attached to it
    8.   //-->Start dialog
    9. } else if (!characterMotor.canControl){
    10.   //If there is no active Dialog (anymore) but the player controls are still disabled
    11.   //-->Reenable character controls
    12. } else {
    13.   //No dialog is active
    14.   //-->Manage target objects
    15. }
    16.  
    Currently the code to disable the character controls are in the first block, eventhough they'd make more sense in the second one, I think (they have to be disabled only once every time you start a conversation).

    I hope this could help!
     
  26. AdamSingle

    AdamSingle

    Joined:
    Apr 18, 2013
    Posts:
    13
    Hello Macorig,

    great tool, I haven't had a heap of time to play with it yet, but it looks perfect for what I need. I was just wondering how the graphics are actually handled? The art for the panels? The panel generation? etc. Would it be possible to tie this in with 2D Toolkit? which I'm currently using for my UI.

    EDIT:
    I just noticed it uses a DialogSkin (though I don't know what that is exactly) which has the textures you're using in there. I assume I'll need to roll with that. The strange thing is the 'button' textures (called button, button hover, button active etc) don't seem to exist in the project, but they aren't missing in the DialogSkin's inspector. Seems strange.
     
    Last edited: Oct 30, 2013
  27. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Hi AdamSingle,

    yeah, the UI integration is pretty messy in the current version and for future versions I hope to get it fixed. If you don't want to use Unity's default GUI system I'm afraid you'll have to rewrite all the parts in the "Dialog.js" file which handle GUI.
    "DialogSkin" is a GUISkin object which defines the different styles: under "Custom Styles" you'll find "choice", "choiceactive", and so on, which are the styles used by the dialog system. The "button" textures are textures for Unity's default GUI, which is why they don't show up in the project hierarchy.
     
  28. Errorjack

    Errorjack

    Joined:
    Nov 14, 2013
    Posts:
    38
    Hey man, great work with this. Is it possible to add support for "proximity" or trigger area talking? I'm making a top-down game and it doesn't even want to function without a first person controller.
     
  29. xZekro

    xZekro

    Joined:
    Jun 21, 2013
    Posts:
    1
    I'm sorry, can you make a tutorial about how use it? I really need it, but I don't know how use it. I tried many times, but it still not work in my project D:
     
  30. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    @Errorjack
    If you want to use it without an FPS controller you'll have to rewrite/change the DialogController script. The idea is that you find an active Dialog Component and then use the functions Load(), Show(), NextNode(), BrowseUp(), BroseDown(), etc. to control/render it. The current script uses a raycast to determin which DialogComponent is the "active" one - of course you can use triggers instead.
    Actually I've already created a script like that before for a small project I'm working on currently, maybe I can find the time to edit and post it next week.

    @xZektro52:.
    I'm afraid I'm really caught up in personal projects and university assignments currently...
    if you have specific issues you can feel free to send me private messages and I'll try to help as good as I can, though!
     
  31. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    @ErrorJack

    You can try this. Make sure your Player-GameObject has the DialogController component and its tag is set to "Player". Add the DialogTrigger-Component to a GameObject that has both a trigger and the Dialog-component you want to activate and see if it works.

    DialogTrigger.js:
    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4. private var dialogController : DialogController;
    5.  
    6. function Start () {
    7.     var player = GameObject.FindWithTag("Player");
    8.     dialogController = player.GetComponent(DialogController);
    9. }
    10.  
    11. function OnTriggerEnter(other : Collider) {
    12.     if(other.gameObject.CompareTag("Player")  dialogController)
    13.         dialogController.SetTarget(this.gameObject);
    14. }
    15.  
    16. function OnTriggerExit(other : Collider) {
    17.     if(dialogController.GetTarget() == this.gameObject)
    18.         dialogController.ClearTarget();
    19. }
    20.  
    Rewritten DialogController.js:
    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4. @System.NonSerialized
    5. var activeDialog : Dialog;
    6. private var target : GameObject;
    7. var dialogSkin : GUISkin;
    8. var allowMouseSelection : boolean = true;
    9.  
    10. function Start () {
    11.  
    12. }
    13.  
    14. private var blockV = false;
    15. private var blockH = false;
    16.  
    17. function Update () {
    18.     if(activeDialog) {     
    19.         //Input to switch to the next dialog node
    20.         if(Input.GetButtonUp("Fire1")) {
    21.             activeDialog.NextNode();
    22.         }
    23.        
    24.         var v = Input.GetAxisRaw("Vertical");
    25.         var h = Input.GetAxisRaw("Horizontal");
    26.  
    27.         //Allow the vertical axis to be used to scroll through answer options
    28.         if(!blockV  Mathf.Abs(v) > 0) {
    29.             blockV = true;
    30.             if(v > 0) {
    31.                 activeDialog.BrowseUp();
    32.             } else {
    33.                 activeDialog.BrowseDown();
    34.             }
    35.         } else if (Mathf.Abs(v) <= 0)
    36.             blockV = false;
    37.         //Horizontal axis also activates the next node
    38.         if(!blockH  Mathf.Abs(h) > 0) {
    39.             blockH = true;
    40.             activeDialog.NextNode();
    41.         } else if (Mathf.Abs(h) == 0)
    42.             blockH = false;
    43.     } else if(Input.GetButtonUp("Fire1")  target  target.GetComponent(Dialog)) {
    44.         //If there is no active dialog, activate the current target's dialog, when
    45.         //the left mouse button is clicked
    46.         activeDialog = target.GetComponent(Dialog);
    47.         activeDialog.allowMouseSelection = allowMouseSelection;
    48.         activeDialog.Load(activeDialog.startNode);
    49.     } else {
    50.         //
    51.     }
    52. }
    53.  
    54. function ClearTarget() {
    55.     target = null;
    56. }
    57.  
    58. function SetTarget(t : GameObject) {
    59.     target = t;
    60. }
    61.  
    62. function GetTarget() : GameObject {
    63.     return target;
    64. }
    65.  
    66. function OnGUI() {
    67.     GUI.skin = dialogSkin;
    68.  
    69.     if(activeDialog) {
    70.         activeDialog.Show();
    71.     } else if(target  target.GetComponent(Dialog)) {
    72.         //Draw the target's nametag
    73.         var screenPos : Vector3 = Camera.main.WorldToScreenPoint(target.transform.position+target.GetComponent(Dialog).nametagOffset);
    74.         var name = GUIContent(target.GetComponent(Dialog).characterName);
    75.         var rect = GUILayoutUtility.GetRect(name, "nametag");
    76.         GUI.Label(Rect(screenPos.x-rect.width*0.5, Screen.height-screenPos.y-rect.height*0.5, rect.width, rect.height), name, "nametag");
    77.     }
    78. }
    79.  
     
  32. Alienguard2000

    Alienguard2000

    Joined:
    Mar 8, 2014
    Posts:
    11
    Hey, your dialogue system seems to be interesting and useful. Would you happen to have a C# version of it? If not, can I translate it for my own needs? Sorry, it's just that I don't like working on javaScript. Anyway, thank you for your work and for posting it for us.
     
  33. macorig

    macorig

    Joined:
    Dec 27, 2010
    Posts:
    49
    Hi there!
    Woah, it has been a while. I haven't started to work in C# until recently. So far there is no C# version of this, even though I do plan to completely recode it in C# (and clean it up a little at the same time) at some point, but I don't think I'll be able to do so any time soon, unfortunately.

    Of course you can change anything you want to fit your project – if you want to translate it to C#, feel free to do so.
     
  34. chino01

    chino01

    Joined:
    Jul 19, 2014
    Posts:
    6
    Hi everyone, First thank you macorig for creating an awesome thing and putting out for free. Actually I've been working on the system on C# for two days.
    And finally the dialogue system is working.. I just could'nt figure out the editor part.
    It compiles and you can use the system just like in the example project.
    But the NodeWindows on the editor, allthough they compile, they don't work because I'm really a beginner and couldn't sort it out. There're bugs that I'm trying to convert Nodewindow to a DialogNode and vice versa and stuck there. If anybody want to help me out I'd really be happy.
     
  35. chino01

    chino01

    Joined:
    Jul 19, 2014
    Posts:
    6
    Hello Everyone with the help of macorig I could be able to fix some bugs and dialog editor works on C# now. We only need to solve save problem for now. It could be because of inherited NodeWindow classes and couldn't figure it out to override the save method. Here're the files with example project.
    http://bit.ly/UoMjMi
    Probable bug on DialogWindow.cs. Let me know if you fix it, please :)
     
  36. chino01

    chino01

    Joined:
    Jul 19, 2014
    Posts:
    6
    Bug Update:
    If I override the Save method I'm creating an ifinite loop I think and getting a memory error. If I don't override the methods it saves the file but with wrong attributes on XML so it won't load. :)

    Code (CSharp):
    1. OutOfMemoryException: Out of memory
    2. System.Array.Resize[Int32] (System.Int32[]& array, Int32 length, Int32 newSize) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Array.cs:1928)
    3. System.Array.Resize[Int32] (System.Int32[]& array, Int32 newSize) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Array.cs:1912)
    4. System.Collections.Generic.List`1[System.Int32].set_Capacity (Int32 value) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:622)
    5. System.Collections.Generic.List`1[System.Int32].GrowIfNeeded (Int32 newCount) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:100)
    6. System.Collections.Generic.List`1[System.Int32].Add (Int32 item) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:91)
    7. DialogWindow.SortNodesByOrder (System.Int32[] nodes) (at Assets/DialogSystem/Editor/DialogWindow.cs:522)
    8. DialogWindow+SwitchNodeWindow.Save () (at Assets/DialogSystem/Editor/DialogWindow.cs:331)
    9. DialogWindow.Save () (at Assets/DialogSystem/Editor/DialogWindow.cs:741)
    10. DialogWindow.OnGUI () (at Assets/DialogSystem/Editor/DialogWindow.cs:713)
    11. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
  37. chino01

    chino01

    Joined:
    Jul 19, 2014
    Posts:
    6
    Hello everyone; system finally works properly in C#. I'm not a good programmer at all so it can be buggy, but it works for me. Thanks macorig for creating the system and helping me.
    Here is the: Example Project Files
    Hope you use it on your projects.
     
    SpyChar and John-G like this.
  38. domini

    domini

    Joined:
    May 16, 2014
    Posts:
    9
    Thank you both (macorig and chino01) very much for this one, I just had a short search for some kind dialogue system as I plan to try to do something with the new 4.6 GUI. As I have most experience with csharp it's great that there is already a translated version to start with. I only tried the example project and started the editor for now, but it looks promising. Now I only need some more time ^^

    Edit:
    noticed that Case-Values get not saved to xml currently

    Update: fixed it
    File: DialogWindow.cs
    In the area "SwitchNodeWindow", "override Dialog.DialogNode Save ()":

    Code (csharp):
    1.  
    2. ...
    3.             Dialog.Case[] tmpCases = new Dialog.Case[sortArray.Count];
    4.                 for(int l= 0; l < sortArray.Count; l++) {
    5.                 CaseNodeWindow caseNode = (CaseNodeWindow)GetNodeWindowByID(sortArray[l]); //fixed
    6.                 Dialog.Case newCase= new Dialog.Case();
    7.                     newCase.caseID = caseNode.windowID;
    8.                     newCase.caseValue = caseNode.caseValue;//fixed: added
    9. ...
    10.  
    suggestions:
    Don't get me wrong, I like to have somethign that already is working how it is, only some ideas that come to my mind after I had to understand the code to fix the small problem that those caseValues didn't got written to the XML-File ... it took me some hours and trial and error, even if it's only those few files of code.

    I find it currently difficult to read the code and one thing I think that could be improved is how the NodeData is handled. Currenty xml gets loaded and from that data those edit windows are generated. Then for saving this data back into xml the code reads the windows.

    Wouldn't it be better to have some kind of structured Object that contains all the data and changes are made to this object and then the windows bind to that data?
    Saving the data would read the object not the windows. I think that would be easier to read.

    Maybe someone who learned or knows how to clean up the code could help out?
     
    Last edited: Oct 31, 2014
  39. varunvp

    varunvp

    Joined:
    Jul 11, 2014
    Posts:
    57
    Hey, just wanted to know, if it would be fine to use this for a commercial purpose. It's a really great and useful tool and would save a lot of time for the game which I'm working on.
    Thanks!