Runemark Dialogue System / Dialogue Behaviour
The Dialogue Behaviour handles almost every runtime functionality that the system has. The DialogueGraph is the plan for a house but, the Dialogue Behaviour is the worker who actually builds up the house.
There are four setting sections in this component. You can expand these sections and the first thing you will see, is an Enable Toggle.
You have to have one Dialogue Behaviour on each Actor you want the player to interact through conversations, or you want the Actor to fire Ambient Dialogues (Barks).
If it’s enabled the dialogue system will use the Name and the Portrait you set in this section. If the Name is empty but set to Enabled, the system will use the GameObject name as Actor Name.
Important: Text Node overrides these settings; in that case, even if it’s set to Disabled, the system will show the Name and Portrait already set in the Text Node.
In this section you can define how you want to trigger the dialogue, want to use custom cameras as well as want to reposition the player character when the dialogue pops up.
Triggering the conversation will call the Conversation event in the dialogue graph.
There is five different option you can use triggering a dialogue.
Trigger Enter: Very easy to use. You can select a Tag to filter the GameObject that can trigger the dialogue. Also you have to add a Sphere Collider to this game object, and set its type to trigger and set it’s radius as you wish (I use 5 unit).
Use Auto Exit: If turned on, the system will close the conversation automatically, depending on the trigger you are using. If set to Trigger Enter, the conversation will be closed when the player exits the trigger. In case of Use, it will be closed if the player goes farther than the use distance. In case of Custom, you can set an Exit Distance, that works same as in case of Use. You can’t however use Auto Exit in case of OnStart.
Exit Delay (Only visible if Use Auto Exit is enabled): You can set a number of second by with you can delay the close of the dialogue. 0 means the conversation closes instantly.
OnStart: A simple type of trigger, where the dialogue starts when the scene is loaded.
Use: If you are using this type of trigger, you need to call the Dialogue Behaviour void Use(Transform other) method in runtime. The other parameter should be the Transform of the player. You can set the player tag as in the Trigger Enter / Trigger Exit method, and also a distance parameter. The Use method will check if the other transform has the right tag, and is within the given distance.
Custom: If you want to trigger the dialogue in a different way, you can select this method, and call the Dialogue Behaviour void StartDialogue() method in runtime through script.
Override Player Position
Sometimes you want to see the player character on a certain position, to make the most of out your conversation. You can do it by setting the player tag, and the Position in this part. The Player Position accept only transforms. This only repositions the player when the conversation starts.
Use Custom Camera(s)
If you want to change the view during the conversation, you can do it here. You can drag and drop multiple cameras from the screen to the Cameras List.
Default Camera Index: this camera will be active during the conversation, when the current Text Node custom camera is Disabled. If this value is set to -1 the game main camera will be used instead.
What is Camera Index? This is the index number of the Cameras list. It start with 0 at the top of the list, and increments by 1 every element below. That’s being said, the first camera in a list has the 0 index, the second camera has the 1 index… and so on.
You can set the skin you want to use for this conversation. You can find more information about Dialogue Skins and how to create them later in this documentation.
Ambient Dialogue (Bark)
In this section you can setup your ambient dialogue (Tutorial). The Trigger part of this section works the exact same way as it does in case of the Conversation.
Triggering the Ambient Dialogue will call the OnBark event in the dialogue graph.
Time: The behaviour will call the OnBark event in the dialogue graph in this interval. The time is measured in seconds.
This section is another option to communicate with systems outside of the Dialogue. This works pretty much the same as the Unity UI Button OnClick events are working.
You can add multiple Events to a single Dialogue Behavior. Every event on the same Dialogue Behavior should have an unique name. This name is used in the Call Event Node.
You can add multiple functions to a single event to be called when the event is fired.
Class Reference (advanced useage)
Important: This part is for those who have basic C# knowledge, or can use unity events!
public void StartDialogue()
This method will start the dialogue. Only works if the Conversation Trigger is set to Custom.
public void StopDialogue()
This method immadietly stops the dialogue, and therefore will close the active dialogue window too.
public void SelectAnswer(string id)
This method will select an answer. This method is called from the ui script as default.
public void SelectNextAnswer()
Same as the Select Answer, but no id needed, becouse it selects the next answer if exists.
public void StartBark()
This method will start the ambient dialogue. Only works if the Ambient Dialogue Trigger is set to Custom.
public void StopBark()
This method immadietly stops the ambient dialogue.
public void Use(Transform other)
This method will start a dialogue if the other transform has the right Tag and is whithin a given distance. Only works if the Conversation or the Ambient Dialogue trigger is set to Use.
public void CallEvent(string eventName)
Calls an event in the Dialogue Graph. The eventName should be the name of the Custom Event Node.
public T GetRootVariable<T>(string variableName)
This method returns the value of the root variable of the given variable name.
public void SetRootVariable<T>(string variableName, T value)
This method sets the value of the root variable of the given variable name.