Official support thread for the Unity Dialogue Engine Advanced

Hi all

After the great success during the Summer Sale, a great many new people have joined the UDEA flock and with that many new people on board I’m sure there is bound to be a few teething problems so I figured I would post a one stop location to find answers to your questions.

Right to start off with, one of you posed a question that I myself am a bit confused with. As you know, if you install my kit, the NGUI scene works off the bat but one person is having a bunch of errors in the NGUI scripts. Why the NGUI code will work in one project but not the other is a mystery to me.

Here’s an example:

As you can see, now suddenly the UITiledSprite.cs script is suddenly no longer working… I am guessing the problem is that the files are placed in folders where they simply can’t see each other and that is what is causing the problem. Since I’ve not had this issue come up before I think it’s solution might take a while to find but we’ll get this sorted eventually.

I’m just curious, though, if anyone else has had this issue also. If so, did you figure it out? Am I correct in my assumption?

I’ll update this thread as I know more.

Turns out the error is in the upgrade from one version of NGUI to another. I tried importing my kit first then NGUI but no luck. So I tried installing NGUI first and when installing my kit I remove all scripts and DLLs belonging to the redistributable version that is included in my kit and voila!

My project imported on top of NGUI with 0 errors and the demo scene still worked just fine :slight_smile:

So there you have it. If you already have NGUI in your project, do NOT install the NGUI scripts or DLLs from my kit (in the Assets//NGUI/ folder). Only keep the prefabs and text files and shaders and that stuff as well as the scripts in the Demos/NGUI folders :slight_smile:

Do you have any documentation on calling UDEA functions from my own GUI system? All of the documentation I could find was related to formatting the XML.

Hi nevilleshane

Sure thing, mate. For some extra formatting options you can look in UDEA.cs for extra functions but everything I don’t list below is just gravy.

In order to create your own GUI system, the first thing you need to do is create a new class that subclasses the UDEA. See the included display. After that, you just need to create an OnGUI function to handle the actual display of your dialogue. If you want to do something fancy like 3D characters or speech bubbles or whatever, do so wherever and however you feel like. As long as you’ve subclassed the UDEA, you are good to go and just need to display the dialogue on screen however you feel like it.

The only exception to the rule is if you want to create your own keyboard input to replace that which I include by default. By default the arrow keys navigate the choices and also, the enter key and the left mouse click continue the dialogue. If you are not happy with this then you just have to override the HandleInput function and you are good to go.

So, a skeleton display would look like this:

public class myDisplay : UDEA {
    void OnGUI()
    {
    }

    //override public void HandleInput() {}
}

That’s it. Now you just need to flesh out the OnGUI function and you have your own custom display file.

Following is a list of the stuff you can use in your GUI…

//globally accessible values
CMLGameKeys   GameKeys        // All GameKeys
eUDEAState    State        // check if ANY dialogue is active
string        Language        // language to use with localisation (if used)
    
//public properties (i.e. access via code only)
Texture2D WhoIsSpeakingAvatar   // fetch/load/generate avatar image for this turn
Texture2D _currentAvatar        // the avatar to show after it was fetched/created
bool HasEnded                   // is the current object's dialogue active or not? 
bool CurrentIsChoice            // is the current turn a choice turn or not?
int CurrentOptionCount          // how many choices does this turn have?
int Selection                   // index of selected choice
string WhoIsSpeakingName        // name of actor speaking this turn
cmlData CurrentLine             // raw access to current turn's details
string     FormattedText        // the text to show on screen
        
//public variables (i.e access via inspector)
string     FileName            // file that contains the dialogue
bool     TypewriterMode        // display text gradually or not?


//public methods
OptionSelect(int val)         //manually specify a choice
OptionPrevious()              //navigate choices backwards
OptionNext()                  //navigate choices forward
string CurrentOptions(int x)  // the text of the relevant choice


//parse a dialogue script and speak the first turn
StartDialogue ()
StartDialogue (int atIndex)
StartDialogue (string filename)
StartDialogue (string filename, int atIndex)

//properly ends the dialogue immediately
EndDialogue()

//progress through the dialogue
int Speak ()
int Speak (int id)

Normally you would set the filename in the inspector and then just call StartDialogue(0) (for instance) and just call Speak() to continue through to the end. That truly is all there is to it…

So, let me write you a very basic skeleton display to use a base (if you don’t want to use the included one as a base, that is):

public class myDisplay : UDEA
{
    string prefix = string.Empty;
    public int StartingIndex = 0;

    void OnGUI()
    {
        if (HasEnded) return;

        if (CurrentIsChoice)
        {
            for( int i = 0; i < CurrentOptionCount; i++)
            {
                prefix = (i == Selection) ? "* " : "  ";
                if ( GUI.Button(new Rect(5,5 + (i*30), 450, 25), prefix + CurrentOptions(i) )
                {
                    OptionSelect(i);
                    Speak();
                }
            }    
        } else {
            GUI.Box(new Rect(5,5,450,120), FormattedText);
        }
    }

    override public void HandleInput()
    {
        base.HandleInput();
        if (Input.GetKeyDown("s")  HasEnded)
            StartDialogue(StartingIndex);

        if (Input.GetKeyDown("escape")  !HasEnded)
             EndDialogue();
    }
}

That’s it. I haven’t tested this, obviously, but it should work just like it is.

In terms of creating your display, that is all you need to do for a functional GUI. From there you can flesh it out as you see fit. Then of course there is the other stuff relating to the keys and the events etc but that is more about using the UDEA with your game, not specifically your GUI so that will come in another post. Right now my finger is real sore from all the tapping. I think my iPad has a dent in it’s screen by now :stuck_out_tongue:

I trust this is what you were looking for?

1 Like

Thanks for the quick reply!

I’m actually using EZGUI, but this points me in the right direction. I’ll give this a try later in the day and get back to you if there are any questions.

Hi!

First of all great asset its working great with my game!
I’m having some trouble using the save system you mention that the UDEA is capable of. Do you have any examples of how to use it?

Thanks!

Hi Tony

Thanks for the kind words, first of all. :slight_smile:

Right, the save system is actually really straight forward. As you go through your game you write whatever info you deem to be important to your gamekeys. So now the time comes to save. What now? The answer is simply to call the Save() function and you are done. It literally is that simple.

When you create your gamekeys you can pass in the name of a file that can be found in a resources folder as a constructor parameter or you can just leave it blank and then pick from any of the 3 load methods to fetch your data from a folder, PlayerPrefs or Resources folder. I tried to give you choices so whatever you wanted to do, you could.

So, for example, in a project I am currently working on I decided that I wanted to have easy access to my save game info during development so I wanted the data to be visible in my project so I can just double click on it and then edit my database in MonoDevelop. When building the game, though, I want to use PlayerPrefs to avoid any issues with paths and whatnot. So… how did I do this fancy save system? Like so…

static public void Save()
    {
    #if UNITY_EDITOR
    database.SaveFile("Assets/Resources/"+database_name+".txt");
    AssetDatabase.Refresh();
    #else
    database.Save(database_name);
    #endif
    }

Unfortunately this project is protected under NDA so I cant tell you more about it but I can say that it is a huge undertaking with a very complex inventory and data structure and it all goes into a single CML file and THIS is the entire Save() function I use for this game.

Loading is just as interesting. Here is an example of how you would tackle it. Simply create a new script for all your data and load it during your splash screens so it is always available.

public class myData : MonoBehaviour
    static public myData Instance;
    CMLGameKeys database;

    public string database_name = "GameData";
    void Start()
    {
        DontDestroyOnLoad(gameObject);
        Instance = this;

        database = new CMLGameKeys();
        //optionally....
        //UDEA.GameKeys = database;

        #if UNITY_EDITOR
            //load from Resources folder
            database.LoadFile(database_name);
        #else
            //load from PlayerPrefs
            database.Load(database_name);
        #endif
        
        //if the database is empty then this is the first time
        //the game is being played so set some default values...
        if (database.Count == 0) {
            //I like to imbed my CML header at the start of my files
            database.ImbedCMLData();

           //now, create some settings...
            database.AddNode("Settings", "Volume=0.5;Tutorial=true");
            database.Last.Set("SelectedPlayer", "Blaze");
            database.Last.Set("PlayerPosition", "(0,0,0)");
            database.Last.Set("PlayerRotation", "(0,0,0,0)");            

            //now create some game keys...
            database.Add("Gold", 2000);
            database.Add("Level", 1);
            database.Add("HP", 100);
            database.Add("MP", 5);
            Save ();
        }
    }

    public Vector3 PlayerPosition {
       get { return database.Vector("Settings","PlayerPosition")); }
       set { database.Set("Settings", value.ToString(), "PlayerPosition");} }
}

Doing what I did above will allow you to fetch the player’s saved position by just saying
transform.position = myData.Instance.PlayerPosition;

So, if you want to save the player’s position along with everything else in the database, just set the value before you call Save. For instance, in your GUI you could have a button called “Save Game” that calls function “DoSaving()”. This function would be written as such…

void DoSaving()
{
    GameObject player = GameObject.Find("Player");
    myData.Instance.PlayerPosition = player.transform.position;
    myData.Instance.Save();
}

There is obviously an infinite number of ways how you can use the save system but what it boils down to is this:
Step 1. While playing the game, store anything you want to save into the database. (Since UDEA.GameKeys is already created FOR you, just use that instead of creating a duplicate. Alternatively, if rewriting all your code to use “UDEA.GameKeys” instead of “database” like above is going to become an issue for you, then simply set UDEA.GameKeys = database; in the Start function.

Step 2. When you want to actually save your data, just call one of the available Save() functions in the UDEGameKeys: Save() or SaveFile()

Done. :slight_smile:

1 Like

I created a video showing how to get started with the UDEA. This starts with an empty project and shows everything from adding characters, creating dialogue scripts and all the way up to creating a player character to use with the UDEA and place a character in the scene to have a dialogue with.

This video should be most useful for all people who are new to the UDEA. Enjoy.

Nice tutorial video.
Du you speak realy that fast :wink:
Maybe you can make one with ngui as an action hud too?

It is sad that is now only is for talking. As it was cml i remember there could be so much more done with it abd for that i would like to see also tutorials as examples :frowning:

Hi Rand

The Actions hud is the first product on the “Free products” page on my website: http://www.mybadstudios.com/?page_id=89

As for the CML, that is a bit of a tricky one… I love CML. I honestly can’t do any project without it. All my new kits come with it as a base or integral part because, as you say, it is very useful. Unfortunately, CML is a standard like XML or .INI files so giving examples of what the data looks like is not very impressive at all but showing what you can do with the data, well… billions of uses depending on how you want to use your data at any given point in time… Literally, I would have to make a demo showing how you use data. Hmmm… A bit… generic/ vague, don’t you think?

Lol. Imagine me starting the video with: “Hi everyone. In today’s video I will be showing you how to use booleans and integers. This is the first video in this tutorial series. Please come back next week when I will have released the second video entitled ‘How to use floats and Rect’. And now, on to the tutorial…” :stuck_out_tongue:

One day, if I can figure out how best to do that I would certainly love to introduce people to CML yes, I just don’t really know ho to showcase the power in a video, yet… :frowning:

Ahhhh…. Tricky, tricky…

See, if you have keys collected elsewhere and you want to retain those but reset all that you got in THIS level, there is no way for me to know which data belongs to THIS level. See the problem? Somehow you will need to tell me what keys need to be set to what values but since they were set in the dialogue scripts that means finding them first then creating variables for each … and I’m not even going to go beyond that as this is already not acceptable.

So, two options here:

  1. If the database contains nothing that you want to keep (unlikely) then you can just call UDEA.GameKeys.Clear() when the game starts and boom… Instant reset.

  2. If you want to retain some of the keys but not all AND be able to reset heir values, I think the simplest method would be to make a copy of the database and restore it afterwards. Have a look at this:

CML duplicate;
void OnLevelStart()
{
	duplicate = new CML();
	duplicate.Join(UDEA.GameKeys);
}

void OnContinueToNext()
{
	duplicate.Clear();
}

void OnReset()
{
	UDEA.GameKeys.Clear();
	UDEA.GameKeys.Join(duplicate);
}

I think that should work just june. :slight_smile:

Hello, I was wondering if there were any tutorial videos explaining some of the more advanced features of UDEA?

Such as using UDEA as a quest or inventory system, triggering custom scripts, or as a save game system.

The videos in your youtube channel don’t cover these topics very thoroughly.

Thanks!

Unfortunately there are no videos for that no. Primarily because I don’t consider them “advanced” features. I consider them rather “simple”… They are like Macs, they just work… no effort required on your end :stuck_out_tongue: :smile:

Once you understand how the GameKeys class works, you will understand why I say this…

If you scan just 5 posts above yours you will see some info on the save system. Basically, the GameKeys class allows you to store int, floats, color, vector2, vector3, rects, quaternions, booleans and strings AND use them during runtime so if you simply use the GameKeys class to define and use your variables then all your game data is already in the database and saving your game is as simple as calling one line of code. Obviously this will have a performance impact so there are some steps you can follow to improve on that but still… a video to explain one line of code is serious overkill in my mind…

Of course, if there is something that you simply CANNOT understand, you are more than welcome to drop me an email and I will personally show you how it works, what to do, how to do it and give you some samples to go with it… I have absolutely no problems with helping my customers. Feel free to ask away! :slight_smile:

In fact, one customer was asking about how to make a quest system so I took an hour or two (I forget how long now :stuck_out_tongue: ) and I went and created an actual quest system that I now give away for free. Have a look here for the scripts. The UDEA makes life so easy when it comes to creating new things for it that this entire quest system literally only took an hour or two from conception to finished product and is so bloody simple that it doesn’t even need a read me file :stuck_out_tongue:

Download, have a look and if you still feel stuck on anything, drop me an email… :slight_smile:

Hello everyone. Its been 2 days now and I’m still facing these problems, kindly guide me how to solve it

  • user provided line number with no dialogue to show: 1
  • Unable to start dialogue

Hi Mustafa

The way this kit works is that when you start the dialogue, you tell it what line to start on, from there on you only call Speak(), not Speak(int) so it can decide for itself what line to speak next… If, however, you DO decide to call Speak(int) then the kit honours your request and goes to the line you told it to speak, ignoring it’s own internal logic.

Now, if you tell it to go to a line that does not exist… well… if it overrides its own logic and tries to speak a line you specifically requested only to find the line is not there, it will throw out an error saying it can’t do that.

An easy way to do this mistake is on a line that gets called repeatedly. Say for instance you have a single turn that has 9 lines of text but you only show 4 lines of text at a time, in this instance, the same line will be called 3 times before moving on so if you have an external variable that tells the kit what line to call and that variable calls the turn to be called for a 4th time, that will also throw out an error.

Other situations are handled internally to avoid error messages like you experienced.

Now, according to that message it is trying to call turn 1 but it cannot find turn 1 so let’s just make sure there IS actually a turn 1, shall we? Open up your dialogue script and find the first node. Make sure that that line looks like this:

<turn>id=0

Then make sure all other turns follow the same pattern but obviously they go id=1, id=2, id=3 etc etc etc… Make sure there is one with id=1 and then you will not have that issue any more :slight_smile:

If you are still struggling, contact me via email and send me your dialogue script and I will have a look and see what is up. Or, since you are online now, find me on Skype and I’ll help you out right now. I’m gonna be around for the next few minutes so let’s quickly get you sorted out :slight_smile:

Skype: mybadstudios

Also, don’t forget, there is a visual editor included in the project. Open up your script using that and then go to the Test tab. From there you can easily debug your script for validity by seeing how the UDEA would treat your script if it were to open it and start from the beginning…

Hey guys

I’ve been promising this for a long time now and it finally got approved…

A while ago I released the MBSCore kit and told people that everyone who buys it will get $10 to $15 discount on my other kits, including the UDEA. Well, the UDEA Core is now live on the store:

If you already own the MBSCore product then feel free to get this at $10 less than the standalone version. Just install MBSCore with this version and you are good to go :slight_smile:

Just a head’s up… UDEA 2 is around the corner… and you are not gonna believe the extra flexibility it offers you! :smile: Keep an eye out for it…

In the mean time, enjoy UDEA Core

Hey again

Thought I’d drop by and just point out that the original UDE is currently available for free on the asset store, in case you missed the announcement. It is only temporary, though, so if you are curious about the UDEA but want to try before you buy, get the original UDE and try it out for yourself.

Of course, the UDE Advanced wouldn’t deserve the added “Advanced” if it wasn’t a lot more powerful than the UDE so be aware of that little fact. It’s a full dialogue engine with all the bells and whistles, the UDEA is simply far better… plain and simple.

Speaking of better, I thought I’d drop in the current change log for the new UDEA 2.0 which is due to be released soon.
EDIT:Okay, the changelog is a bit long… TLDR version:

  1. No more OnGUI prefabs included, UGUI all the way now
  2. Audio system added, including a barking system. I.e. characters can speak random audio at random times
  3. Created an entirely new keys system that changes the way you work with the kit. It is so much more user friendly than before!!!(Which makes the UDEA2 incompatible with UDEA projects, unfortunately)
  4. Now includes a Visual Novel prefab. Single drag and drop and you are ready to go.
  5. Made enabling OnGUI and visual systems compatibility as simple as a single click in the inspector
  6. Now returns both Texture2D and Sprites for the avatars
  7. You no longer need to specify if a turn is a choice or not. UDEA2 figures that out automatically
  8. Removed stuff that was not part of the UDEA: The shop and ActionsHUD
  9. Demo scenes showcasing multiple input methods: OnTriggerEnter, mouse click
V.2.0
- Added a change log
- Added AutoContinueOnClick boolean to UDEA. Enable to continue the dialogue with a left click
	Disable to allow the UDEA to be used with NGUI/ UGUI / etc.
- Added CurrentSprite property alongside CurrentAvatar property. You can now fetch a Sprite or a Texture2D
- WhoIsSpeakingAvatar now first tries to load a Sprite and loads a Texture only if that fails
- Removed the use of the ProcessKeys function to handle custom keys
- Custom keys now directly calls any function you want. The first param of your key is the function name
	For example, a custom key "ChangeVolume BGSource 0.4" will send the params "BGSource" and "0.4" to a
	function called ChangeVolume
- Custom keys can now have any number of parameters or none at all. If using parameters they will be passed
	as a single cmlData object so be sure to create your functions like this: public void FuncX(cmlData data)
- Custom key's parameters can now be prefixed with a descriptive name using the : seperator
	Example: [keys] ChangeVolume WhichItem:BGSource Volume:0.4 FadeSpeed:0.15, KeyWithNoParams
	Parameters without names are accessed in the order they are declared, ignoring named parameters before it
	Paramteres with names are accessed by name and can be converted to it's relevant type
	Example:	Using key "ChangeVolume BGSource, Volume: 0.4, 0.15" with function: FuncX(cmlData fields)
				string bgSource = fields.data[0]; <-- accessed via data array. First entry
				float volume = fields.Float("volume"); <-- accessed by name. Converted to type
				float fadespeed = float.Parse( fields.data[1] ); <-- second entry in data array. Value returned as string
- Added UGUI display prefabs
- Removed old OnGUI displays and prefabs
- Now require that the dialogue be parented to a canvas, no longer simply run directly on random objects
- Dialogue prefabs are now destroyed instead of disabled so there is now a difference in implementation
- Removed "Parent" property from UDEA class as it was just a duplicate of the public "parent" variable
- Removed redundant OpenFile and StartDialogue methods
- Changed CurrentIsChoice function to look at nuber of redirect values, rather than implicit "choice" value
- Removed the need to add "choice=true" in dialogue scripts. This is now completely redundant
- Made the OnSpeakStart, OnSpeakEnd,OnTypewriterModeUpdate and OnSelectionChange events local events, not static
- Removed the ActionsHUD product from the UDEA. The ActionsHUD is and alwyas was a stanalone product included
	for demonstration purposes. It will always be available for free at  www.mybadstudios.com if you still want it
- Fixed a bug with WhoIsSpeakingName if called after the dialogue contents were cleared
- Added an Audio system to the UDEA. Just drag the audio prefab onto an object, add some clips to it and you
	can now play audio right from your dialogue. Simply add the key "PlaySound track:trackname" where
	trackname is the name of a track you added to the prefab. Alternatively you can also use "PlaySound index:x"
	where x is the array index of a clip you added to the prefab.
	You can also add in "loop:true" or "loop:false" if you want. i.e. "PlaySound track:help loop:false"
- Added a barking system. Use the same audio system and add the sentences you want the character to speak
	Simply tick the "random_barks" box and specify the min and max wait time between random barks. Primarily used
	to make guards say random stuff, in the demo I use it to play random electrical beeps and crackles on the
	damaged robot. Turn this barks system on or off during dialogues using "DisableRandomBarks" or "EnableRandomBarks"

The UDEA2 has UGUI displays by default already making it a worthy upgrade even if only for that reason.
As with the UDEA, the UDEA2 makes it super simple to create you own custom displays so to demonstrate it, here is the code for the main display file used in the screenshots below…:

public class DialogueDisplayMethod1 : DialogueDisplayBase {
	
	public Image
		choice_avatar_image;

	override public void CheckForChoices(object source, UDEAEvent data)
	{
		choices_parent.SetActive(CurrentIsChoice);
		plain_text_parent.SetActive(!CurrentIsChoice);
		if (CurrentIsChoice)
		{
			choice_avatar_image.sprite = CurrentSprite;
			for ( int i = 0; i < choices_text.Length; i++)
			{
				choices_text[i].text = (i >= CurrentOptionCount) ? string.Empty : CurrentOptions(i);
				if (i == Selection)
					highlight_image.rectTransform.position = choices_text[i].rectTransform.position - new Vector3(20,0,0);
			}
		} else
		{
			actor_name_text.text = WhoIsSpeakingName;
			avatar_image.sprite = CurrentSprite;
			dialogue_text.text = FormattedText;
		}
	}
}

That’s it. 30 lines of code for a custom display. Simply derive from the base class and update only what you need to. The rest of the work is done visually in UGUI.

Next big thing to note that that all this time I have been telling people that adding audio to this system is so darn easy that I didn’t even bother to include it in the kit. Instead I just showed those who asked me how to do so. Well, now the kit includes a dedicated audio prefab. Just drag it onto the object, add the clips that objects should be able to speak and you are done. Simply use the new key PlaySound to play it whenever you are ready. No more custom scripting required.

In fact, I even updated the audio system to allow your characters to play random audio clips if you wanted to. Audio, not text. Guards bored on patrol, guys expressing their opinions while playing poker, princess saying cutesy things, whatever… Again, all without a single line of code from you.

This brings me to probably the most important change of all… Those of you who have the UDEA will know that you can trigger external code by just adding a key and then having a function called ProcessKeys that deals with your keys, right? Well that entire system is now gone. In the UDEA2 you can now create your own functions in any script on your object and call them directly from your dialogue. The old limitation that you must have a key name and 2 parameters is no longer present. You can now have 0 to infinite params and you even have the option of assigning your parameters names…

I’m sure that must have raised a few eye brows, huh? :smile:

Anyway, more info as and when… Just wanted to drop by for an update.
Oh, and of course, let’s not forget the fact that the Vikings have finally been retired and the UDEA2 now has a new demo scene using models graciously provided by 3DForge… So here is some screenshots from the GUI created with the code posted above.



Another sneak peek at one of the new prefabs included in UDEA version 2.0

1 Like

I just bought this and was a bit disappointed to see it still used the OnGUI system. I Then read the forums here and saw you do have a new version for UGUI on the way in V2.0. Do you have an estimated time of when V 2.0 will be released ? just looking for a rough time a week,month, 2 months, etc…so i can plan accordingly. Also out of curiosity does this asset include your core kit ? Thanks

Fabulous! Is it really as easy as you say it is? :slight_smile: I have two teens who are preparing their own visual novels and this looks perfect for them. Once we help them with the uGUI, is it really just drop and drag for the visual novel?

At the current price, we will get it regardless. But the easier it is to use, the better it is for me since I can spend more time on my project and less helping them. :slight_smile: