Dialogue by Narrenschlag
First. Thank you for your purchase. Welcome to the documentation of the Dialogue package. If you have any suggestions, ideas or innovations to add to this please feel free to contact me.
First Steps (Setup)
At first make sure to download the latest version of Cutulu. You can download it on my itch website for free. It adds the core utility and handy functions, my packages require to work.
Now you can import the package by drag’n’drop or by right click>>import package.
Check the sample assets and the sample scene out to get a basic understanding. Your scene normally only requires the following prefabs/scripts to already work:
DataManager.cs (Script of Cutulu)
Dialogue Interface (Prefab of Dialogue)
DataManager
This script is made to be overwritten/inherited on by your own save system but comes with a simple PlayerPrefs sample that you can use without modifying it.
Dialogue Interface
This prefab has to be added to your Canvas. Make sure to set the CanvasScaler.cs to Scale with Screen and use a reference resolution of 1920x1080. This is not required but I made the prefabs for that scaling and it is a pretty nice to work with aswell, as normal screens have that ratio.
On the prefab there are a number of important scripts that make the whole thing work. Here is a little walkthrough.
Distributer.cs
Basically a manager that handles all the requests and provides all the utility and functions you will use from outside the package to access it easily and fast.
It enables the functions you can see below the following scripts.
Conversation.cs
Component.startDialogue(TreeAsset, id)
Component.startDialogue(TreeAsset)
This script handles all of the conversations, awnser options, etc. It is basically the manager of the whole operation. It reads from the TreeAsset fed into it.
Using string-cmd, a utility addon I added to the Cutulu API for this use case, you can call internal functions of scripts with args to more easily enable your writers and coders to access data in your game and increase efficiency. Further down I will explain this more.
With startDialogue you also define a target for the function calls to be broadcasted on.
Inputs
string.inputString(Action<bool, string>, bool)
string.inputFloat(Action<bool, float>, bool)
string.inputInt(Action<bool, int>, bool)
Defining all three input methods at once here as I am too busy to write poems for each of them. So basically the string base is used as the interface title, the action as a callback for your functions on submit or cancel of the player and the bool as an indicator if it can be cancelled.
Audio
The package comes with a simple character based audio system that reads the char currently being placed and plays a tune based on it.
Exporting the Dialogue Tree
By opening the TreeAsset in the inspector and providing a path you can import and export it as .txt file to your StreamingAssets/dialogue folder by pressing the editor buttons.
You can edit the .txt files in an text editor aswell or give them to your writers to edit them easily and import them back in.
Languages and Translation
You can utilize the Cutulu API to localize your dialogues by using the given addon. Just enable it in the Conversation prefab and in the dialogue tree text boxes provide the (string)id-names in the translation-file so the Translator can easily use it.
You can enable it by toggeling the Translate Text bool on your Distributer. Be aware that you need to setup your Translator first.
String-CMD
This is actually quite simple to understand. It is basically used for the following.
Reading and Writing Data to your dialogues (names, gold, etc.)
Call functions in a given GameObject by using BroadCast()
Formatting in TextMeshPro-RichText
Syntax and Samples
in text: “hello my name is {v:s:player_name; log:I<3U}”
In a text string you want to use the ‘{’ and ‘}’ for definition.
You may use ‘:’ for argument seperation.
v => value
s => string
player_name => Retrieves key:“player_name” from DataManager.cs
The second command is declared after seperating it from the last with ‘;’.
log => Debug.Log
I<3U => Prints “I<3U” to the console
in cmd-line: “v:s:player_name; log:I<3U”
In the cmd-line you do not need the ‘{’ or ‘}’.
String-CMD in your dialogue
The structure is quite simple to understand and easy to use. So how would it work? Here a sample for you.
So basically it writes the text to the body until a cmd is found. As it is found it pauses the writing and executes the cmd. If the cmd causes a return string it will be added to the text body aswell (for name reading from data f.e.). If it doesn’t find a return string value or the string has been added to the text body it simply continues writing until there is no more text to write or another cmd is found (repeats the cycle).