Unity 3D Dialogue Tool v. 1.0

So, after getting some feedback on YouTube, I've decided to release my Unity 3D Dialogue Generator under a GNU GPL.  Have fun, and if you make improvements to it, please let me know.

Download the Unity Package (~1.8mb)

Youtube Demo 2

Input and corrections are always welcome.

Derivatives:

Note: It appears that newer versions of Unity do not allow the Eval() expression. This is probably good, because it slows things down to a crawl, but without it, you can't really do much in the way of Inspector-driven logic. So, if you're having errors with the Eval() function, I don't think there's much that can be done to fix it.

Comments

I love the look and ease of use with your Dialog Generator! Thanks a bunch! I'm having issues getting the script to do actions on answers though. If you could please see my post in the Unity forums for more information on my issue. I've been trying to get this to work for literally days with no luck. I'm probably in over my head but any help would be awesome.

http://forum.unity3d.com/viewtopic.php?t=62819

Thanks!
Will Moreno

Royce Kimmons's picture

What script are you using?

It should be something like:

------------------------------

GameObject.Find("YourObject").GetComponent(YourScript).YourAction();

------------------------------

So, when the dialogue is over, this script will:
1. Find a game object in the scene named "YourObject";
2. Find the attached script "YourScript";
3. And run the function "YourAction".

In this scenario, you should have an object in the scene named "Your Object" with a script attached to it named "YourScript". Within "YourScript", you should have a function called YourAction.

For example:
------------------------------
function YourAction () {
print ("Hello world!");
}

------------------------------

I just tested this and it seemed to work fine.

Good luck!

Wow, I've actually been thinking of how to script a dialogue manager but this one just make things so much easier.

I do however have some questions I'd like to ask. First, is it possible to put images inside the dialogue box? For instance, images of a game character that switch images whenever they are talking to another character? If it is, how should I approach this?

Secondly, how do I trigger a dialogue? For instance, how do I execute a dialogue after a certain time or whenever a character walks into another character/object to interact?

Hope you can help.

Thanks very much.
-Hakimo

Got it working by making an empty project and wrote my own game dialogue manager. Made a variable for the gameobject(myDialogue) and created a timer to call the dialogue after a certain time. Is that the way to do it?

Also, is there way to make the text play automatically? I'd like it to play automatically and only use the button to speed the dialogue.

Thanks again for the dialogue generator.
-Hakimo

Royce Kimmons's picture

Hi Hakimo,

Glad you're finding some use for the tool!

I'm pretty sure that there is an image feature in this version. I'll look in the next day or so and if not, I know that I created one that supports images. I was even working on one at one point that pulled in full-size images (Fire Emblem style); maybe I can dig it up.

Calling the dialogue after a time works, or there should be a DialogueTrigger script in there, I think. Otherwise, all you need is some type of detector (click, rigidbody, etc.) that enables the script (e.g. GameObject.GetComponent(DialogueInstance).enabled = true; ) to turn on the dialogue. I didn't work on that too much, because different implementations would require different requirements (like locking the screen, locking movement, etc.).

Regarding the autoplay, again, I don't remember exactly in this version, but I think this uses the gradual text feature for displaying. You could edit the DialogueInstance script to start a timer once the text is fully displayed (and if there are no choices to be made) which will proceed to the next dialogue item in the queue after a second or two. Or, if you're attaching audio, it could proceed once the audio finishes. This would be a good add on for me to build in later, but it shouldn't be too hard to get going in the current implementation, I don't think.

Hope this was somewhat helpful. Will get back to you on the images feature.

Royce

Cheers Royce. I'll try and see what I can do :)

Royce Kimmons's picture

Check out the derivative I just posted in the main body of the page. It uses images in a major way and should be tweak-able for your needs.

Wow! Thanks again Royce. I'll definitinely have a go at it :)

I am using your dialogue editor for prototyping and have two questions (somewhat related):

1. If I have created a large dialogue script with branching paths that I would like to move from one game object to another, is there an easy way to do that?

2. If not, is there somewhere that I can easily access the dialogue I have 'written' in the editor (something like an XML file)?

Also, I have created a small dialogue toggle script that I attach to game objects so that when I click on them, the dialogue comes up or disappears. The only problem with it is that it crashes Unity if I forget to initially turn your dialogue editor script off. Here it is:

var clickTarget: String;

function OnMouseOver () {
if (Input.GetButtonDown ("Fire1")) {
var npc = GameObject.Find(clickTarget);
var dialogueScript = npc.GetComponent("DialogueInstance");
dialogueScript.enabled = !dialogueScript.enabled;
}
}

Thanks for this tool!

Royce Kimmons's picture

Hi Andrew,

Glad the tool's working for your needs!

The main thing to understand which I think gets at both of your questions is that all data in the tool is stored as class variables in Unity. This is nice, because it allows you to easily edit them in the inspector, but is problematic if you want to move them.

1. What I've done in this situation is to create a prefab, drag the current object (with all the dialogue data in it) to the prefab. This replicates the entire dialogue instance and allows you to reuse it, move it between scenes, and so forth. Once you've done that, you can then instantiate the prefab (or edit it directly) and change the mesh, materials, etc. as your needs require.

2. Again, since the data is stored within Unity, there are no files to copy or move. If you needed to get your data out, you'd need to write a custom script which pulls up all of the dialogue instances and writes them to a file in a way that would be useful for you. Ideally, it would be nice to have a script that wrote these instances in an XML tree and then could import them back, but I haven't needed to do this yet, and even if there were such a tool, there'd be data loss, because the tool references unity objects in the current scene (like image files, gui skins, and so forth) which are stored as Unity identifiers.

3. One thing you might try, if you've already got a toggle script that you're using with all dialogue instances, is to have it check on start for an attached DialogueInstance and to disable it, like so:

function Start () {
var d : DialogueInstance = gameObject.GetComponent(DialogueInstance);
if (d) d.enabled = false;
}

This is untested but should do the trick of disabling the dialogue before it causes problems. Additionally, in your script, I think that you have an error in the GetComponent() call, because DialogueInstance should not be in quotes (if you're doing a Find command, you need quotes, but since Unity recognizes DialogueInstance as a script, you can call it directly). This might be a problem.

Hope this helps,

Royce

1. I am getting problems trying to replace the mesh ("Number of bind poses doesn't match number of bones in skinned mesh."). I think this means I'm not going to be able to replace the mesh I want to here. This isn't much of a problem as the script I created isn't something I need to keep. I just wanted to test this for future use.

2. I had a feeling this was the case. Thanks.

3. That worked great. Having the code check is great in case I forget to disable the script. The error you pointed out in my code actually works. I'm not sure why, but that code works with or without the quotes.

I have determined a solution for moving the dialogue and/or changing the mesh. The solution requires that your model (in Unity) has a top level gameobject that has the dialogue, etc. attached to it. That is, your mesh should not be the top level object. This allows you to change things like the mesh without reattaching scripts, etc.

Instead of trying to replace the mesh on the model, the model (which is one level down from the top level object with all of the dialogue and a sphere collider if you are using my toggle script) can simply be deactivated or deleted. Then, a new prefab mesh can be added as a child to the top level object that has the dialogue script attached.

Thank you so much for this. I'm gonna use it as learning tool to make my own visual novel engine on Unity3D :)

Royce Kimmons's picture

Glad you like it! Let me know what happens with your visual novel engine.

Hello! first of all, amazing script man! you're very talented!

Secondly, does this work on the iPhone? just curious how much it can be extended!

Cheers!

Royce Kimmons's picture

Thanks for the kudos!

I don't have the iPhone version of Unity, so I haven't been able to test it. My guess is that it should work for the most part, but there might be some issues with the selection wheel stemming from screen size (it currently uses static pixel values centered on the screen which may be too large for an iPhone).

I quickly set up a small test and I like the whole thing already. I am yet to understand how choices and the rest work but for the moment I encountered a small issue when building on android. I had to comment this line (178): eval(display.script);
from DialogueInstance.js - got a message about not being supported on Android platform. It works however with that line commented and I was wondering what that actually does.
On another note, I would like to help you out with a new skin and test forward the features on Android for you.

Royce Kimmons's picture

Can't look at it now, but I'm pretty sure that's used to evaluate custom scripts you feed the interface to be executed in response to a selection (e.g. change a variable if the user makes an important choice), and so, it's only necessary if you're going to have it evaluate your own scripts fed through the interface. The basic dialog functionality will still work fine without it.

And new skins are good. :) If you finish one, let me know and we can post it.

Im using the scripts for my game and its great, how ever i try'd to change something in the Guiskin and it completely ruined the Gui. and it can't be fixed by redoing it or reimporting the guiskin file

this is the only thing id like to comment about the dialog system :)

Perhaps a pdf with a step to step how to use tutorial
and a bit friendlier way to costumise the GUI looks

Rest of it works great !

Royce Kimmons's picture

It sounds like you changed a Unity variable and that Unity remembers it even if you reimport the GUIskin file. You may want to try completely deleting the file and then importing it again, though you will need to reconnect any existing dialogue instances to the new skin. Or, you could create a new project, import the GUIskin file, and recording what the variables are so that you can update the current project.

I'd like to do a lot more work on this, and tutorials would be a great addition, but alas, time does not permit at the moment. Maybe in the near future, though.

AMAZING SCRIPT! how did you show the ninjas and knight? using imageAbove? and how did you placed the name of the guy there, I was unable to!

Royce Kimmons's picture

Thanks! Try downloading the alternate version http://kimmonsdesign.com/sites/default/files/dialogue2.unitypackage and tweaking it. It should have everything you need to get the images showing up.

first of all, thank you for this wonderful tool that you're sharing.

I started editing it with no problem, but I can't align properly the character image, check the image below:

http://i.imgur.com/Gvczt.png

I tried messing around with the skin property of imgs but still no effect.

thanks !

I think I got it by adding 2 variables to the script, for X & Y position, check the link below.

http://i.imgur.com/5MfJy.png

Now I have to bring the image to the foreground, ^^

That works great man! thanks!!! problem solved with that! just one question though: how can the dialogue be unskipable? I mean you can click at the right button and it flies by, how can this be changed to "not until the dialog has ended"?

Sorry, I am a script noob here, just wanting to know how can I use this script? I mean how do I set up a message and make it appear when I click on a box ?
Thanks for any help!

Royce Kimmons's picture

Hi Popsi,
You will need to attach the DialogueInstance script to an object and set it up the way you want. When you play the scene, the script will start automatically (showing the dialogue). If you don't want this to happen, you will need to disable the script (unclick the box) and create a script of your own to enable it at the right time (typically using OnColliderEnter [if you want to run into the object] or a Raycast of some kind [if you want to click on the object]).

Ok! I think I've got it. I will try it when I'm home.
Thank your for your kind assistance!

Hello Royce, Firstly thanks for sharing this great work with us. You've designed a very nice tool congratulations :)

Secondly, I would like to ask you some questions about it. I am trying to close the dialogue box once you've correctly answered a question, and also I am trying to dissapear that button below once you choose something from the selections, so that dialogue box will not be shown second time.

Can you please tell me how can I do those ? As I coudn't figure it out :/
Many thanks again.

Royce Kimmons's picture

Hi Mus,
One thing you can do is when making choices, make the correct choice point to a new dialogue item that says "Correct!" or something like that and set the mode to "End." This way, if they click the correct answer, it will say the correct message and then disable the dialogue instance (until it is enabled again).
If you want to do something fancy when they select the right answer, you will need to use the "Script" mode. So, for instance, you can have the correct answer go to a dialogue item that destroys the object by using the script GameObject.Destroy(d.gameObject); or go to a dialogue object that just destroys the dialogue instance (i.e. removes it from the object) using the script GameObject.Destroy(d);.

Hi Royce,
Thank you for your response. I've already tried what you've first said but I don't know how to set it's mode to End I think :))

I've found that mode bit from the inspector panel but can you please tell me what value do I need to put there ? Thanks

Hi Royce,
I am also trying to add a score counter. I tought may be I can achive that creating a new "case" for the correct answer however is continues to add up values to the score once I have selected the right answer. Do you have any idea what might be the problem is? Or do you have any other suggestions? Thanks

Hi,

First off, let me tell you that this script is amazing!
Second, I would like to ask you for some help...
Is it possible to push a button on your keyboard instead of the next button with the mouse? Like, for instance if I want to continue (where you normally push the next button on screen with the mouse) I push 'E' instead?
If so, that would be awesome.
I have some scripting knowledge so if you tell me where and how I can change it myself

Royce Kimmons's picture

Hi Everlight,
At one point I had that functionality in the script (with the right arrow key), but may have removed it.
To add key listening, you will need to add something like the following in the Update function:

if (Input.GetKeyDown(key ID goes here)) {
// advance the dialogue
}

I don't remember the function to advance the dialogue off the top of my head, though. I'll try to check later.

pretty simple now that I think about it...

In your code you have this:

function DoNextButton () {
switch(display.mode) {
case 0:
if (lineCount

Royce Kimmons's picture

Coolness!

See, I thought I had made it easy; just can't always remember ... ;)

How do I change the font size for the Dialogue Text Field?
I've tried modifying the GUI setting, but nothing changes

Sorry to ask such a dumb question.

Royce Kimmons's picture

Hi Dave,
To change the font size, you will need to duplicate the actual font file in your assets panel, give it a different name, change the size there, and attach the new font to your GUI Style.

Ok! Thank you ! Royce

Hi Royce,
Is there any way to add time interval between messages?

Royce Kimmons's picture

Hmm... not built-in I don't think. But you might be able to do something in the script mode by using a yield statement.

yield WaitForSeconds(2);

Or something like that.

OK I think I've got it.
Thanks! Royce

Hello there royce can you help me with problem ...
I donwload and unzip it and than copy to my asset folder of my project but unity dint recongnize it ... i import it and nothing happend cant use it ... its .tar and unity cant open it or something and when i extract that .tar file nothings happend too
do you know where is problem, probably.. ? thanks

Royce Kimmons's picture

Hi Pali,

You shouldn't need to unzip it, since it is a .unitypackage file. Just open Unity and import to the assets folder.

Royce

Hello!Thanks Royce for this awesome Dialogbox..uhmm can you teach me how to resize it?..http://i189.photobucket.com/albums/z36/ucutmywrist8/test-3.jpg because it's covering some of the GUI

Royce Kimmons's picture

Hi Jasper,

You'll need to edit the script directly. Go into DialogueInstance.js and change the code at line 127 from GUI.Box(Rect(0,Screen.height-120,Screen.width,120),curContent,"textboxplayer"); to GUI.Box(Rect(0,Screen.height-120,[NEW WIDTH],120),curContent,"textboxplayer"); where [NEW WIDTH] is the width you want. For your purposes, you might want to try something like Screen.width-300 or something like that.

Royce

Hello Royce,

First of all, congratulations for the great packaged. This dialogue tool is really simple to use yet very powerful.
I'm currently making a game and I would like to know which one is the license of your dialogue tool. This site says it is GPLv3 which I have to release my source code if I distribute my game, but the source code of this tool says the license is Creative Commons Attribution 3.0 License, which I have use as long as there is aknowledge to you.
Which one is it?

Thanks

Royce Kimmons's picture

Great, Tom! I'm glad you're getting use out of it.

I need to figure this out. I originally released it under CC BY 3.0, but then when I repackaged it with the Battle for Wesnoth images in the second example, I needed to release it under GNU-GPL (because that's what Wesnoth uses).

So, my intent as the author is for you to use it under a CC BY (attribution only), which is why the scripts are labeled as CC BY, but if you use the package with the Wesnoth images, then it would need to be GNU-GPL. So, as long as you only use the stuff created by me (i.e. the first link above) and not the Wesnoth stuff (i.e. the "beefed up" version), CC BY is the license that you would need to abide by.

Does that make sense? I think I can do that.

That's great. I am no pro in js (I program in C#), but if I use your dialog tool, I might upgrade it a little and I'll get back to you with a newer version.

Thanks

Hello Royce,

I had written some scripts in the script mode and they works, however How do I continue the dialog after running the script?

I had tried adding commands like "LoadDialogue(display.next);" but it doesn't work.

Thanks!

Pages

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.