One-click to complete the dialogue needs? You can't miss this plugin (Unity3D)

One-click to complete the dialogue needs? You can't miss this plugin (Unity3D)

Recommended reading

I. Introduction

Dialogue System is a branched unified conversation system. It does not require any scripting, but it is designed to be easily extended by programmers.

The Unity dialogue system allows you to:

  • Use branch logic to write interactive conversations.
  • Display conversations in a flexible, fully customizable UI system.
  • Define the task/task to be completed by the player.
  • Play sequences of shots, such as camera clips and audio.
  • Save and load games, and persist data during scene changes.
  • Use localization to display text and play tailored scenes in different languages.
  • Import and export various formats, such as draft, Chat Mapper and CSV.

Effect picture:

2. Download address

download.csdn.net/download/q7...

3. the text

1. Start

Set up

If your project uses Unity 5.x, you must first change to forced text serialization

  • Edit Project Settings Editor
  • Then change Asset Serialization to Force Text and Version Control to Visible Meta Files

Next step

Demonstration scene

Demo scene The demo scene is played in Plugins Pixel Crushers Dialogue System Demo to see how the dialogue system works

How to play

  • Use arrow keys or WASD keys to move.
  • Use the mouse to watch.
  • View the interactive objects and press the space bar to interact.
  • Left mouse button to shoot.
  • Press "ESC" to open the "Pause" menu.

Demonstration task You can do this in the demo scene:

  • Get the launch code (task): Talk to Private Hart to get this task. It involves finding a password in the next room and interacting with the computer.
  • Enemy Attack (Task): Talk to the NPC in the next room to complete this task. It demonstrates how to set up a counter-based task, in this case a killing task.
  • Change the scene and interact with the door to change the scene. This demonstrates how to preserve data during scene changes.
  • Save and load mini games Use the "Pause" menu to save and load the game.
Overview

The dialogue system consists of the following main parts:

  • Dialogue database: Contains dialogues, tasks and variables.
  • Dialogue editor: edit the dialogue database. You can also import and export third-party formats.
  • Dialogue Manager: Manage dialogue system activities at runtime. Provide prefabs.
  • Dialogue UI: Display interactive dialogues, alarm messages, task logs, etc.
  • Interactive system: Trigger activities at runtime, such as starting a session.

Dialogue database is an asset file that contains sessions, tasks, and user-defined variables. You usually use a dialog editor to edit its content, although you can also import content from several other formats.

The dialog database contains design-time content and fields edited in the Unity editor. At runtime, the dialogue system treats the dialogue database as a read-only database; it loads the dialogue database fields into places where the values can be changed during the game.

Conversation editor

Conversation manager

The dialog manager is a GameObject in your scene, it coordinates all the dialog system activities and saves the runtime data of the dialog system.

Dialogue UI

The dialogue system uses the following UI:

  • Dialogue UI: Run interactive dialogues and alert messages. (As shown above)
  • Task log window: Display the player's active tasks and completed tasks.
  • Task Tracker HUD: Display tracking information of active tasks.

Interactive system

The dialogue system provides components that interact with GameObjects and performs operations such as starting a dialogue and updating task status.

Localization

The dialogue system supports the localization of dialogue database content and general UI elements.

Extended dialogue system

Although the default functions of the dialogue system are very powerful and flexible, you can also create your own logic functions, crop scene operations, UI types, and so on. This can be written in a script.

Quick start

This section skips directly to using the dialogue system to create and run sessions. You will learn how to:

  • Create a conversation database and write conversations.
  • Set the dialog management GameObject.
  • Start the conversation.
  • Interact with objects.
  • Disable player controls during the conversation.

step:

Step 1. Create a new scene (File New Scene).

Step 2. Drag the prefab Assets Plugins Pixel Crushers Dialogue System Prefabs Dialogue Manager into the scene:

Step 3. This GameObject has pointed to a basic dialogue UI, we need to create a dialogue database, let us click Create:

Step 4. After specifying the path and name for the database, click the dialog manager GameObject again. Click the Edit button or the dialog system icon. This will open the "Dialog Editor" window:

Step 5. Click the Conversations tab.

  • Click the "+" button to add a new session.
  • Right-click the orange START node and select Create Child Node. Click on the child node and enter the "Hello." field in the Dialogue Text of the Inspector panel
  • Right-click the gray node ("Hello."), select Create Child Node to create a child node, and enter "Good Bye." again
  • The gray node is said by the NPC, the blue node is said by the player. Your conversation should look like this

Step 6. Create an empty game object for the player (GameObject Create Empty) and a Cube for the NPC (GameObject 3D Object Cube). Rename the empty game object to "Player". Rename the Cube to "NPC" and set its position to (0, 0, 0) to make it visible in the "Game" view.

Step 7. Click on NPC. Add a dialog system trigger:

Step 8. Click Add Action and select Start Conversation:

Step 9. From the Conversation drop-down, specify the Conversation field as New Conversation 1, and assign Player to Conversation Actor and NPC to Conversation Conversant.

Step 10. Finally, set Trigger to On Start. This tells the dialog system trigger to perform its action at the beginning of the scene.

Step 11, now start your first conversation! The dialogue system will display the NPC line ("hello."). Following this is the Player Response menu, which contains an option ("Goodbye."). It uses a basic standard dialog UI, which is a universal template, you can customize it later to view any content you want.

Next, we will start the conversation using the interactive system.

Step 12. Set Trigger to On Use. This tells the dialog system trigger to perform its action when receiving an OnUse message, usually from an interactive component on the player.

Step 13. Add Usable component. This tells the player s interactive components that the maximum use distance that an NPC can be clicked on is 30

Step 14. Click on the player object and add a Selector component. Set Select At to Mouse Position:

Step 15. Now play the scene again. Place the mouse on the cube so that you can see the following yellow message:

This means that the player's selector component has detected the available components of the NPC. Press the space bar or the right mouse button. The Selector component will send an OnUse message to the NPC, and the NPC's dialogue system trigger will respond by starting the session.

Selector component and similar component, Proximity Selector component, provide methods to trigger the dialogue system activities. They can be customized. You can configure them to choose many different methods, not just using the mouse cursor. Using them is also not mandatory. If you want, you can use your own interactive system or C# code to run the dialog system trigger.

Step 16. You may notice that the Selector component remains active during the session. In many cases, during the conversation, you will want to disable the selector and possibly other components such as player motion and camera control. One way to do this is to add a dialog system event component. This component has events that run on various dialogue system activities. Configure to disable the selector at the beginning of the conversation and re-enable it at the end of the conversation:

Summary This quick start demonstrates how to:

  • Create a conversation database and write conversations.
  • Set the dialog management GameObject.
  • Start the conversation.
  • Interact with objects.
  • Disable player controls during the conversation.

2. Conversation editor

Dialogue database

The dialog database is an asset file. To create a conversation database:

  • Click the Create button of dialog management.
  • Or choose Assets Create Pixel Crushers Dialogue System Dialogue Database

The conversation database contains the following categories:

categorydescription
Database databaseSet description, author and version, and database scope
ActorsConversation participants (players, NPCs, interactive objects)
Items/Quests task systemTask definition
Locationslocation information
VariablesUser-defined variables to judge dialogue decisions
Conversationsdialogue

Here is a detailed introduction to each category

Dialog edit window

To open the dialog editor, you can use the menu item Tools Pixel Crushers Dialogue System Dialogue Editor or click the logo banner of the dialog manager, or double-click the dialog database resource. The dialog editor window works with the Inspector view.

Database database

Database Properties:

  • Author: Author
  • Version: Version
  • Description: description
  • Global User Script: Global User Script, which can load the Lua code set by the database at runtime
  • Emphasis Settings: Emphasis settings, you can mark and set the color value

Global Search & Replace: Global Search & Replace allows you to search (optionally replace) text in the dialog database. Merge Database: Allows you to merge the contents of another conversation database into the conversation database currently being edited. Export Database: Allows you to export the conversation database to various formats, such as voiceover scripts and CSV (spreadsheets). Localization Export/Import: Localization export/import foldout allows you to export localized CSV files in a simpler format than exporting database foldout. Editor Settings: The editor settings foldout contains settings such as where and how frequently to automatically back up the database.

Actors

The Actors tab defines the participants in the conversation. You can specify the name of the participant (and the optional display name used in the ui), optional portrait image, and so on. Portrait images can be texture assets or Sprites. If you use Sprites for a character, don't assign values to portrait textures. Similarly, if you use textures, don't assign values to Sprites.

Quests/Items task system

The Task/Project tab defines tasks and projects. Items are simply data records that you can use for your own purposes. The dialogue system does not do any special processing on the entries. Tasks are used by the task system, which is explained in detail in the task section. Use this tab to define tasks and optional task entries (subtasks). Your task text can include mark tags. The state is the starting state of the task. This value will not be updated in real time during runtime; instead, view the real-time status of the task on the watch tab. If you want the task to appear on the task tracking interface, tick it to track and track it at the beginning (tracking will be turned on as soon as the task is activated).

Locations

The location is just a data record. The dialogue system will not do any special treatment to the location.

Variables variable

Variables are values that you can set and check in the game. Use them to track information, such as the decisions the player made, the number of goals gained or failed in the mission, etc. The Conversations tab and dialog system components provide drop-down menus to select variables and check or set them.

The dialogue system will automatically create and set four variables at the beginning of the dialogue. You don't have to add them to the database, but if you want to easily reference them in the drop-down menu in the conversation, you can add them.

  • Actor: The display name of the main participant (usually the player) of the conversation.
  • Conversant: The display name of the main conversation person (usually an NPC).
  • ActorIndex: The Actor[] table index of the participant, which provides optional low-level Lua code.
  • ConversantIndex: Actor[] puts the index of the talker in the table.

If your conversation assigns content to the built-in variable Alert, the conversation system will display it as an alert message when the conversation ends. You can also use the ShowAlert() Lua function described in Logic and Lua.

Conversations dialogue

This is the core of the dialog editor. You can use the node editor (shown above) to create, edit and delete conversations. During runtime, this tab displays a real-time view of the current conversation.

Node editor

operatingstep
Create new conversation Create new conversationClick the "+" to the right of the drop-down box of the conversation title.
Edit conversation propertiesClick in the blank canvas area. Used to set the display settings of the title, main participants, and overlay conversation manager.
Add/delete node Add/delete nodeRight-click on the context menu of node. (When adding child nodes, hold down the Shift key to use the same actor assignment instead of swapping them.)
Edit nodeClick on the node.
Edit link arrow Edit link arrowClick the link arrow.
Change display settingsUse Use the Menu menu in the upper right corner.

Inspector view of the node

operatingstep
IDContent ID number
TitleThe optional text is for reference only. Not shown to the player.
Description DescriptionThe optional text is for reference only. Not shown to the player.
Actor roleThe role of saying this line.
ConversantThe speaker speaks to the character (audience).
GroupIf this item is checked, it will be marked as a through node for grouping child nodes.
Menu TextThe text displayed in the player's response menu, such as a brief explanation of the dialogue text. If it is empty, it will default to the dialog text.
Dialogue TextThe text shows subtitles. If it is empty, the default is the menu text. Note: You can also double-click a node to directly enter the dialog text on the node.
SequenceThe cutscenes played when the character utters this line. If it is empty, the default sequence of the dialog manager is used.
Response Menu SequenceThe optional sequence is played in the background, and the response menu is visible. If the player makes a selection in the response menu while playing the response menu sequence, the response menu sequence will end and the sequence of the next dialogue item will start on the same frame.
ConditionsThe condition must be true to allow the player to speak or display the line in the response menu.
False Condition ActionWhat to do when things are not right.
ScriptThe operation to run when the node is called.
OnExecute()Run UnityEvent when this node is called.
Links To LinkUse the drop-down menu to manually set the links, adjust their priority, and adjust their order.

Conditions

You can use the point and click drop-down menu or manual input to add a Lua expression to the condition field to allow the dialog to use the input only when the Lua expression is true. For example, suppose you only want the NPC to speak a line of dialogue when the player visits Paris. You can define a variable "VisitedParis" with an initial value of false. When the player visits Paris, set the variable to true. Then add a condition for the NPC's dialogue entry:

  • Dialogue Text: "So, what did you think of Paris?" "So, what did you think of Paris?"
  • Condition: Variable["VisitedParis"] == true Variable ("VisitedParis") = = true

Evaluate the conditions one level in advance of the dialogue

The dialogue system performs an additional level of evaluation of the link before the dialogue. It must do this to properly handle certain continue button modes. This means that if you set a value on one node (for example, node), then you cannot check it on the next node (node B) because the dialog system will already check the condition of running the node before node B. Instead, you need to use an empty interval node alone to postpone the evaluation condition. To demonstrate this, we will use an example of a coin toss dialogue:

In the example above, the "coin toss" node randomly sets the variable x to 1 or 2. We cannot immediately use the two conditional nodes ("heads" and "negative") for tracking, because the dialogue system evaluates one layer in advance-which means that before the "coin toss" node runs, it has already tested "heads" and " The negative condition.

To solve this problem, we added an intermediate node to the dialogue, set the title to "Delayed Evaluation" to remind ourselves of its purpose, and left the dialogue text blank. Then we set the sequence to None() so that it will immediately enter the next step of the conversation. If you are using the continue button, select "+" Continue Simulate continue button click on the sequence field instead of using None().

When dealing with conditions, temporarily setting the debug level of the dialog manager to Info may also help. This will add a lot of information to the console window. If you read carefully, you will find that the following lines are similar:

The System Dialogue: the Lua (X = Math.random ( 2 )) Dialogue the System: (Pic) Referee '... Flipping COIN' Dialogue the System: Block ON False Link ( Referee ): ID = . 5 : . 3 'Heads!' For condition Condition = 'X . 1 == ' Dialogue the System: the Add Link ( Referee ): ID = . 5 : . 4 ' Tails! ' (True) Dialogue the System: (Pic) Referee !' Tails' duplicated code

Lines 3-4 indicate that the link to'Heads' is blocked because'x====1' is false, but it is adding the link to'Tails' (because'x======2 'Is true).

OnExecute() UnityEvent

The event fold contains a UnityEvent named OnExecute(). Using it is similar to adding an event handler to the OnClick() event of a Unity UI button. However, because the dialog database exists independently of the scene, you cannot assign scene objects. Instead, you must allocate an asset file, such as a prefab or ScriptableObject. Note: UnityEvents is not supported by database export features or third-party format importers.

In the following example, we will create a ScriptableObject asset, which provides a method to play audio clips. Then we assign this method to the OnExecute() event of the dialog entry.

1. create a new c# script called TestScriptableObject, which contains the following code. TestScriptableObject.cs

using UnityEngine; [ CreateAssetMenu(fileName = "TestScriptableObject" ) ] public class TestScriptableObject : ScriptableObject { public AudioClip[] audioClips; public void PlayAudioClip ( int i ) { AudioSource.PlayClipAtPoint(audioClips[i], Vector3.zero); } } Copy code

Next, select Create TestScriptableObject in the project view. This will create an asset file:

You may want to move assets to a folder named Resources. In this way, it will be included in the build. In some versions of Unity, some platforms will strip away assets that it deems unnecessary. This situation usually occurs in scripted object assets, which are not referenced in any scenario.

Check your new asset file. You can assign audio clips to it:

Finally, check the OnExecute() event of the dialog entry node, click the "+" button, and assign TestScriptableObject. Select the method you want to execute (PlayAudioClip), and specify the index of the audio clip you want to play:

Outline Editor

You can also edit the dialog in outline mode, as shown above, which may be more familiar to users of editors like Bioware's Aurora toolset. To switch to outline mode, select Menu Outline

Templates

Use the Templates tab to change the default fields added to new roles, tasks, conversation entries, etc. You can also change the colors used in the outline mode of the dialog tab. The menu in the upper right corner allows you to save and load template settings, fill the template with custom fields that already exist in the database, and apply the template to everything in the database. To add a new custom field, expand the category you want to customize. Then click the gray "+" to provide field details. In the screenshot below, we have added a custom age field for the character. We also chose to tick the main checkbox, which tells the dialog editor to display it in the main inspector section of the actor instead of just showing it in all fields.

Watches

At runtime, a Watches tab will replace the Templates tab. In this tab, you can view the runtime values of variables, tasks, and arbitrary Lua expressions. You can also use the code bar at the bottom of the window to run Lua expressions.

Use multiple databases

It is usually much easier to use a single conversation database. However, the dialogue system supports multiple databases. You need more management of multiple databases to keep track of them, and load and remove memory when appropriate, but they are very useful for breaking down your content, and can be used to organize or reduce any The amount of content loaded into memory at a given time.

Deciding Between Single Or Multiple Databases Deciding Between Single Or Multiple Databases Here are some guidelines to decide to use one database or multiple databases:

  • A dialogue database containing 1000 dialogues of average length requires approximately 15 MB of memory, which is equivalent to several texture files.
  • If you are making a desktop game, 15 MB should not be a problem. In this case, the only reason to use multiple databases is for the benefit of your organization.
  • If you are building a very low-end mobile device, 15 MB may be too much, but in the end it depends on your specifications and needs.
  • A single database is larger than the memory budget you are willing to use, or your database has many different elements, and you need to organize it and split it.

Sync Assets From Another Database

If you use multiple dialog databases, you may want to define all roles in one database, define all tasks in another database, and so on. Then you can configure the dialog database to extract elements from these databases. To do this, select Sync from DB in the menu of the tab. Then select the source database of the elements to be synchronized. You can add more elements, but remember that elements with the same ID as in the source database will be overwritten. For example, suppose you are writing a game and the player travels from one planet to another with a group of partners. You can define player and companion roles in the source database. You can then create a separate database for each planet synchronized from this source database and add specific participants to that planet.

Unique ID Tool Unique ID Tool

If you only use one conversation database, you can skip this page. Internally, each element (actor, item, conversation, etc.) in the conversation database has an ID number. In a single database, for each type of element, these ids are usually unique. However, the ID used in one database may also be used in another database. If two databases are loaded at runtime, the ids will conflict. The dialogue system will not know which asset you have referenced with the given ID. To prevent this, use the unique ID tool: Tools Pixel Crushers Dialogue System Tools Unique ID Tool. Just add the database that you want to guarantee a unique ID, and then click Process. If you check detailed logging, the tool will record all ID number changes in the console.

3. Conversation Manager

Dialog manager prefab

The dialog manager coordinates runtime activities and maintains the Lua environment containing runtime data of the dialog system. Add a dialogue manager, drag pre-made Assets Plugins Pixel Crushers Dialogue System Prefabs Dialogue Manager

The default setting of the dialog manager keeps it the same when the scene is changed and ensures that only one copy exists in the scene. You will usually use a dialog manager to add to your main menu scene. You can place other dialogue managers in your location scene so you can test them without having to enter from the main scene. But remember, in a normal game, the dialogue manager in the main scene will execute and destroy the "test" dialogue manager in your location scene.

Dialogue System Controller

The dialog system controller component saves the settings of the dialog system. Initial Database The dialog manager loads the dialog database when it starts. Display Settings

The display settings section contains the following subsections:

  • Localization settings: Control how to handle language localization.
  • Subtitle settings: Control how the dialogue UI displays subtitles.
  • Camera and cutscenes settings: control how the cutscenes sequencer works.
  • Input settings: Control how the player responds to the menu in the dialogue.
  • Warning settings: Control the way the dialog UI displays warning messages on the screen.

Persistent Data Settings

The Persistent Data Settings section allows you to specify which data is included in the saved game, and which data is saved when the scene changes. Other Settings

The other settings section contains other settings. It is worth noting that:

  • Instantiate the database: Load a copy of the dialog database instead of using the asset directly in the playmode of the Unity editor.
  • Dialogue Time Mode Dialogue Time Mode: By default, the dialogue system runs Realtime real-time mode, if you want to use the time scale, set the Dialogue Time Mode GamePlay
  • Debug level: Set the log level of the dialogue system in the console of the Unity editor, and set the player log file in the build. This is very convenient for tracking through dialogue system activities.

Instantiate Prefabs component Instantiate prefab block: instantiate the basic UI prefab block into the canvas of the dialog manager. These include selector elements (see Triggers and Interactions), as well as task tracking HUDs and task log windows (see Tasks). You can assign different pre-made components to customize the appearance of the game.

Input Device Manager component input device manager: detect the switch between the mouse, joystick and keyboard controls, and help the UI know when to automatically focus the UI button (in the joystick and keyboard mode), and when not to focus the button (in the mouse Mode).

4. Triggering and interaction

This section talks about how to interact

Dialogue System Trigger Dialogue System Trigger

The dialog system trigger component has three main parts:

  • Trigger: The event that causes the dialogue system to trigger.
  • Conditions: The state must be true when the dialogue system triggers the execution of its actions.
  • Actions: What the trigger should do, such as starting a conversation or setting the status of a task.

Trigger can set the trigger to drop down to these values:

Triggerdescription
On UseThe player's selector or proximity selector sends an OnUse message to the GameObject, or manually calls the OnUse() method of the dialog system trigger in the UnityEvent or script.
On StartThe component starts (for example, when the scene starts).
On EnableThe component is enabled.
On DisableThe component is disabled.
On DestroyThe component is destroyed.
On Trigger EnterThe component is enabled.
On EnableThe component received an OnTriggerEnter message. To use this trigger, the component's GameObject should have a trigger collider. You may need to set Conditions Accepted Tags to restrict this trigger to GameObjects Player with specific tags (such as).
On Trigger ExitThe component received an OnTriggerExit message.
On Collision EnterThe component received an OnCollisionEnter message.
On Collision ExitThe component received an OnCollisionExit message.
On Bark StartGameObject starts to play bark game (one-time dialogue).
On Bark EndGameObject (game object) completes the game of bark.
On Conversation StartGameObject only serves as the main participant in the conversation.
On Conversation EndGameObject just ended the conversation.
On Sequence StartGameObject only started as the main participant in the cutscene sequence. Unless you check the dialog sequence in the dialog manager, this event will not be called Subtitle Settings Inform Sequence Start And End
On Sequence EndA sequence has just ended.

Conditions

Condition typedescription
Lua ConditionsLua expressions, such as checking the value of a variable.
Quest ConditionsNeed to explore.
Accepted TagsFor OnCollision and OnTrigger events, another GameObject must have one of these tags. If the accepted tag is empty, all game objects are allowed.
Accepted GameObjectsFor OnCollision and OnTrigger events, another GameObject must be in this list. If the accepted gameobject is empty, then all gameobjects are allowed.

Action

Actiondescription
Set Quest StateSet task and/or task entry state
Run Lua Code Run Lua codeRun Lua expressions.
Play SequencePlay cutscenes
Show AlertDisplay warning messages through the dialog UI.
Send MessagesUse Unity's SendMessage() method to send the message to the target.
Start ConversationStart a conversation.
Set GameObjects Active/Inactive Set GameObjects activity/activityWork on the entire game object.
Set Components Enabled/Disabled Set components enabled/disabledWork on specific components of the game object.
Set Animator StatesSet the animator state on GameObjects. Useful for idle characters when the dialogue starts.
OnExecute() UnityEventAllows you to specify other actions using UnityEvent.

Selectors & Usables

The dialogue system provides an optional interactive system that can interact with game objects (such as npc) with available components. You can add two components to the player:

Selector

The selector component detects available items by casting a ray from a specified position (such as the mouse position or the center of the screen). When the player presses the use button, it will send an OnUse message to the user.

Proximity Selector

The proximity selector component detects available items when the trigger collider is entered. When the player presses the use button, it will send an OnUse message to the user.

OnUse Message When the player aims at an available and presses the use key or the use button, the selector will send an OnUse (switch player) message to the available game object. The trigger of the dialog system (such as the trigger of the dialog system) responds to this message. Your own script can also respond to this message by adding the OnUse method, for example:

void OnUse ( Transform player ) { Debug.Log( "I'm being used by " + player); } Copy code

4. Conversation UI

Dialogue UI

This chapter explains how to build a dialog user interface and a user interface. The dialogue system uses dialogue ui to display interactive dialogues and on-screen alarm messages. You can customize how each participant is displayed in the UI by adding a dialog participant component.

Standard Dialogue UI Standard Dialogue UI

The standard dialog UI is a set of components used to manage the UI elements shown in the screenshot above. These elements are:

  • Warning panel: Display warning messages.
  • Subtitle panel: Display the dialogue text of the actors.
  • Response menu: displays the responses that the player can choose.
  • Timer: If the dialog manager is configured as a timed response menu, it will display a countdown.
  • Text input: Read text input from the player.

All UI elements can be repositioned and adjusted.

Standard Dialogue UI Prefabs The easiest way is to assign a prefab block to the dialog UI field of the dialog manager. Located in Prefabs Standard UI Prefabs template is:

  • Basic: The default UI shown above.
  • Bubble: The character above the cartoon bubble showing the subtitle panel and response menu
  • Focus: The speaker in each line fades out, while the other actor fades out to 50% transparency.
  • Letterbox: Movie-style subtitles, with black bars at the top and bottom of the screen.
  • VN: Traditional visual novel layout with subtitle/menu box above the larger portrait image.
  • WRPG: Traditional Western RPG layout with rolling dialogue log.

Subtitle Panels & Menu Panels

A standard dialogue UI usually has one or more subtitle panels and menu panels. Assign the subtitle panel to the subtitle panel list. Set the NPC default subtitle panel and the PC default subtitle panel, and specify which panels are used by the NPC and the player by default. An Actor with a dialog Actor component can specify a panel different from the default panel. If it is true that the opening of the subtitle panel is allowed at the beginning of the dialogue, the dialogue system will check all dialogue participants to identify their subtitle panel. If any of these subtitle panels specify that they should be opened immediately at the beginning of the conversation, it will open them. If you know that no panel is configured to open when the conversation starts, you can uncheck this checkbox to bypass it. Assign the menu panel to the menu panel list. Set the default menu panel as the default menu panel. Usually, you will only have one menu panel. In most cases, you will assign the subtitle panel and the menu panel in the same canvas as the dialogue UI. However, it is possible to assign panels located on different canvases.

Subtitle Panel

Menu Panel

Panel Animation Animation Panel The subtitle panel and the menu panel can play animation when the state changes. To assign an animation, add an Animator component to the panel. Specify an animation controller that has triggers in one or more of the following states. The following list describes when to set each trigger:

  • Show: When the panel is open.
  • Hide: When the panel is closed.
  • Focus: When the panel is actively displaying the current line of the dialog text/menu.
  • Unfocus: When the panel is still visible, but does not include the currently active panel.

5. Logic & Lua

Lua Chat Mapper Chat Mapper Lua Lua Lua Lua

Lua

Lua Lua Lua:

  • [lua( )] ( )
  • Lua/DialogueLua ( c# Lua)
  • Lua

Point-and-Click Lua

Lua ( ) a ' :

+ Lua :

Lua

Lua c# UnityScript Lua www.lua.org

6

In a dialogue system, each line of dialogue can be bound to a cinematic sequence-for example, playing animations, audio files, and/or moving a camera. This sequence is specified in the sequence field of the dialog entry. If the sequence field of the dialog entry is empty, it is specified in the default sequence of the dialog manager. During the dialogue, the dialogue system will display the dialogue text of the dialogue entry for the duration of the dialogue sequence. For example, if the sequence runs for 5 seconds, the dialogue text will be displayed as the subtitle for 5 seconds.

How to write a sequence

Scene sequences are defined with simple text-based commands, which makes them very compact and can be added quickly when writing conversations, and can even use external authoring programs such as chat mapper and articy:draft. A large library of sequencer commands is already included, and you can easily add your own commands. The complete list of built-in sequencer commands is in the sequencer command reference. In most cases, if you don't want to manually enter commands, you don't need to do this. If you don't want to specify a sequence in a text string, you can use an interactive editor (such as Unity Timeline) and simply run the timeline using the Timeline() sequalizer command provided.

Using Camera Angles

When you use the camera (x) command in sequence, it first checks the camera angle preset. If it finds a sub-object whose name matches x, it will use the preset offset of the sub-object from the camera angle. Then, it places the camera at the same offset position as the character.

Example: The default camera angle preset has a sub-component named close-up, which is approximately 2 units upwards and 1 unit backwards. The sequencer instructs the camera (close-up) to move the camera up by about 2 units and backward by 1 unit, as shown in the figure below:

The default camera angle preset has another sub-component named "Medium", which is 2 units upward and 2 units backward, which makes the camera a little farther away from the character. To add a camera angle that points to a sitting character, you might add another sub-object, which is only 1 unit up and 2 units back. If the dialogue system does not find a matching sub-object in the camera angle preset, it will look for a GameObject named x in the scene. If it finds one, it treats it as an absolute camera position. It moves the camera to the same position as the GameObject and rotates it. You can add empty GameObjects to the scene and specify absolute camera positions.

Default Camera Angles Default camera angles

The default camera angle prefab contains these angles:

AngleDescription Description
CloseupFront-on head shot Front-on head shot
Closeup Back Closeup BackBack of head Back of head
Closeup Left Closeup LeftLeft side of head Left side of head
Closeup Right Closeup RightRight side of head Right side of head
MediumHead and torso Head and torso
Medium BackBack of head and torso
Medium LeftLeft side of head and torso
Medium RightRight side of head and torso
FullFront-on body
Full BackBack of body
Full LeftLeft side of body
Full RightRight side of body
WideBody with space (farther than Medium shots)
OTS Left OTS LeftOver the left shoulder
OTS Right OTS RightOver the right shoulder
DownLooking down on the subject
UpLooking up at the subject

Camera Angle Editor Camera Angle Editor

You can use the camera angle editor tool to help you create camera angle prefabs. Use the camera angle editor:

  • 1.Select menu item Tools Pixel Crushers Dialogue System Tools Camera Angle Editor.
  • 2. Subject: Assign a role in the scene. The editor will display the camera angle associated with the character in the game view.
  • 3. Camera angle collection: Assign a game object. You can start with the default angle presets in the reference material, or you can create your own angle presets from scratch. If you specify a prefab, you can only edit the existing angle. To add a new angle, you must click the button to instantiate a pre-made scene object.
  • 4. Camera angle: select the camera angle from the drop-down menu. The game view will move to the position of the selected camera angle. To add a new camera angle, click the "+" next to the pop-up menu.

Remember to save your new camera angle collection as a pre-made or scene object so you can assign it to the display settings of your conversation manager.

7. Mission system

The task is usually started and completed by talking to the npc. The dialogue system provides an integrated task system that makes it easy to manage tasks during dialogue and games.

Writing Quests

Use the task/entry section of the dialog editor to write tasks.

Quest Fields

FieldDescription Description
NameThe name of the task in the conversation database. If Use Display Name is unticked, this name is also used in UIs. If this option is not checked, this name is also used in UIs.
Use Display NameUse the name field. field in UIs that is different from the name Name.
Display NameIf Use Display Name uses the display name to be used in the ui name.
Use GroupsGroup tasks in the user interface.
GroupIf Use Groups (checked) will classify this task group.
StateThe start state of the task.
TrackableTasks can be displayed on the task tracking HUD on the screen. Players can switch tracking and turn off.
Track On StartW When the task is activated, it will be displayed in the task tracking interface immediately (tracking is turned on).
VisibleOptional; if true, do not display in the task log window.
AbandonableThe player can abandon the mission.
Has Entries (Subtasks) entries (subtasks)Tasks have subtasks.
Description DescriptionThe description of the task is displayed in the task log window when the task is activated.
Success Description Success DescriptionThe description displayed when the task is in a successful state. If blank the description is displayed.
Failure DescriptionThe description displayed when the task is in a failed state. If blank, the Description is shown.
Entry # Entry#(If (If Has Entries has a description of the item.
Entry # StateEnter #State the starting state of the entry.

Markup Tags Markup Tags You can use tags like [var=varName] and [lua(code)] in the task text. This is often used in entries to display the current task counter value. Localization You can define localized versions of all text fields in the all fields section or the Template tab, such as name, display name, description, entry #, etc. For example, to add the French version of the display name, add the field display name fr. Runtime States The task/entry section of the dialog editor displays the design-time content of the dialog database, not the runtime status of the task. To view the runtime status during playback, use the Watches tab. Example Quest task demonstration This is a task in the dialogue system demonstration scene:

  • Players can switch the task interface Trackable, Track on Start.
  • After the task is completed, there will be a different description (success description).
  • Mark the mark to show the current count, which is stored in a variable called enemiesKilled.

Controlling Quests

Controlling Quests in Conversations Controlling Quests in Conversations You can usually use the point and click Lua wizard to check and set the status of the tasks in the conversation. Quest-Related Lua Functions Quest-Related Lua functions If you want to use quest management Lua functions directly, you can summarize it as follows:

Lua Function Lua FunctionDescription DescriptionExample
CurrentQuestState(questName)Returns a quest state as "unassigned", "active", "success", or "failure"CurrentQuestState("Kill 5 Rats") == "active"
SetQuestState(questName, state)Sets a quest stateSetQuestState("Kill 5 Rats", "success")
CurrentQuestEntryState(questName, entryNum)Returns a quest entry stateCurrentQuestEntryState("Escape", 2) == "active"
SetQuestEntryState(questName, entryNum, state)Sets a quest entry stateSetQuestEntryState("Escape", 2, "success")

Quest Management Triggers You can use these components to control tasks:

  • Increment On Destroy adds counters for destruction missions when killing or collecting targets.
  • Dialogue System Trigger Dialogue System Trigger-general action.
  • Condition Observer-When the condition is true, monitor the condition and perform the operation.
  • Timeline Set Quest State playable Timeline Set Quest State playable-Control the tasks on the timeline.
  • The general-purpose Trigger Event, Collision Event, Timed Event components are also useful for managing quests.

Controlling Quests in Scripts The task QuestLog class in Controlling Quests in Scripts provides methods for adding and deleting tasks, obtaining and setting their status, and obtaining their descriptions. This is a static class, so you can call its methods without having to create a QuestLog object. Note that the task status is usually updated in the dialog. In most cases, you may use the point and click Lua wizard to set the task status during the conversation, so you may never need to use many of the methods in this class. If you use these methods, you don't have to convert spaces and hyphens to underscores (as described in the important notes on table indexes); the QuestLog class will do this for you automatically. Quest State Messages When the task state changes, the dialogue system sends an OnQuestStateChange message. Quest Management Example In the example task above, NPC Sergeant Graves gave the player a kill task in the dialogue:

In the highlighted node, use the point and click Lua wizard to set up the script field. It does two things:

  • Set task activation.
  • Set the alarm variable so that the alarm message is displayed at the end of the conversation.

Each enemy has an incremental destruction component, adding a variable named enemy killed.

The OnIncrement() event of the component also runs the OnUse method. The game object of the dialog system trigger is called the enemy:

Multiplayer mission

How to manage tasks in a multiplayer game depends largely on the design of the game. In many cases, you can maintain a dialogue system environment (including missions) for each player on each client. However, if you are using an authoritative master server, such as an MMO, you may want to verify the task status on the master server to prevent cheating. To do this, assign overriding methods to these delegates:

  • QuestLog.SetQuestStateOverride
  • QuestLog.CurrentQuestStateOverride

In the SetQuestStateOverride method, contact the main server to confirm that the player is allowed to set the requested state. If it is, call QuestLog.DefaultSetQuestState(), which will set the quest state locally, update the tracker, and notify the listener.

In the CurrentQuestStateOverride method, contact the main server to confirm the player's authoritative task status. The use of this method may be more complicated than SetQuestStateOverride. Communication with the main server is usually asynchronous; your override method may not be able to return the quest status immediately because it needs to wait for a response from the main server. Instead, your method can return a string reference for an asynchronous operation. Then, the code that calls CurrentQuestState() can wait for the asynchronous operation to complete and retrieve the quest status from the response, instead of immediately using the return value of the override method as the quest status. Task status is often checked and set in the dialogue. When using an asynchronous override method that does not return a value immediately, you may want to configure the sequence of dialog entries to wait for a sequencer message indicating that the asynchronous method has completed. In the dialog item, use the WaitForMessage() sequencer command to wait for the sequencer message. In the asynchronous method, use the sequencer. message() method to send the sequencer message. If the dialog item is configured to wait for a task state (ie, task state). , You have set CurrentQuestStateOverride), you can register an additional Lua function, you can use this function in the next dialog entry to return the value received from the main server.

If your task uses task entries (subtasks), you can also set these overrides:

  • QuestLog.SetQuestEntryStateOverride
  • QuestLog.CurrentQuestEntryStateOverride

Task interface

Quest Log Window Quest Log Window

The task log window shows the player's active tasks and detailed information about the completed tasks. The recommended way to set the task log window is to use the standard UI task log window component.

**Standard UI task log window** The standard UI task log window manages the UI elements shown in the screenshot above. These elements are:

  • Main panel: Control the switch between displaying active tasks and completing tasks.
  • Selection panel: Display the task title, optionally included in the group folder. Players can switch tracking or select a task to view its details.
  • Details panel: Display the details of the currently selected task.

All UI elements can be repositioned and adjusted.

The easiest way to set the task log window is to use Prefabs Standard UI Prefabs Basic. This prefab is assigned to the instantiation prefab of the dialog manager prefab, which means it will be instantiated automatically under the dialog manager s canvas.

The standard user interface task log window component has the following properties:

HUD mission system

Task indicators

You can use the task instructions to tell the player that the NPC has task information.

Set task instructions:

  • Add the instruction game object to the NPC. For example, add a Unity UI world space canvas with one or more images. For example, a question mark indicates that a new task is available, and an exclamation mark indicates that the NPC has a task update. In the DemoScene2 scene, NPC sergeant Graves has a task instruction canvas.
  • Add a Quest State Indicator to the NPC. This allows you to associate gameobjects (such as world space canvas images) with digital indicator levels. Regarding Sergeant Graves, the indicators are:

Level 0: nothing Level 0: No Level 1: question mark Level 1: Question mark Level 2: exclamation mark Level 2: exclamation mark

  • Add a task status monitoring component to the NPC. When the task status changes, the component will update the current indicator level of the task status indicator, and optionally do other things through UnityEvent (which can be connected in the inspector). To configure the task status listener, add elements to the task status indicator level fold. In each element, specify a task status and the indicator level associated with the task status. The task entry state also has a corresponding folding page. The highest indication level is always priority. If your NPC involves multiple tasks, you can add multiple task status listeners.

8. Save the system

The dialogue system uses the Pixel Crushers Common Library's preservation system. The Save system components are configured in the demo scene. The dialog manager has a save system component and some components related to the save system component:

The demo menu calls the static script method SaveSystem.SaveToSlot() to save the game, and calls SaveSystem.LoadFromSlot() to load the game.

Save system settings

  • 1. Add a saving system component to the scene-for example, on the dialog manager in the demo scene. The Save System component will make the GameObject a persistent singleton object, which means it will still exist after the scene is changed, and there is usually only one instance.
  • 2. Add a dialog system protection program. This component sends the data of the dialog system to the preservation system.
  • 3. Add a Json data serializer component. This component converts binary saved game data into a saveable format in this case, JSON text. If you want to use a different serializer, you can add your own implementation of the DataSerializer class.
  • 4. Add a game data memory saved by Player Prefs or a game memory component saved by disk. This component writes serialized data to persistent storage (such as PlayerPrefs or encrypted local disk files). All platforms support game data storage saved by Player Prefs. The game storage program that supports disk storage in an independent build. If you want to store the game in a different way, you can add your own implementation of the SavedGameDataStorer class.
  • 5. Optionally add a standard scene conversion manager. This component can load an intermediate loading screen scene and/or play animations such as fade in and fade out when the scene is changed. In the demo scene, the transition manager is configured to fade in black during scene changes. For more information, see Scene Transition Manager.

Save component settings

Add these components to the state of any game object you want to save:

ComponentFunction function
Active SaverSave the active/inactive state of the game object. If the GameObject becomes inactive, add this component to a different GameObject that is guaranteed to be active, and assign the target GameObject.
Multi Active Saver rSave the active/inactive state of multiple game objects.
Animator SaverrSave the state of GameObject's animator.
Destructible Saver rWhen saving, the game object has been destroyed or disabled. The next time the game or scene is loaded, if the GameObject has been destroyed/disabled before, this script will destroy/disable it again. If a prefab is specified, it will also produce a broken replacement version.
Enabled Saver rSave the enabled/disabled state of the component. If the GameObject starts in an inactive state, add this component to a different GameObject that is guaranteed to be active, and assign the target component.
Position Saver rSave the position and rotation of the game object.

Save and load

To save and load the game from a script, use the static method pixelcrusher. savesystem. SaveGameToSlot PixelCrushers.SaveSystem.LoadGameFromSlot.

Ways to save the system

To access the Save system method without using a script, for example, in the OnClick() event of a UI button, add a Save system method component and configure the UI button to call the component s SaveSlot and LoadFromSlot methods. Checkpoint save Level save is the trigger area that automatically saves the game when the player enters. Set a checkpoint to save:

  • 1. Create a game object and add a trigger collider. (At least one object, the player or trigger, may need a rigid body to record the trigger conflict.)
  • 2. Add saving system method component.
  • 3. Add a Trigger Event trigger event component

- Set the label mask to an appropriate mask, such as Player. - Configure the On Trigger Enter event to call SaveSystemMethods. Save the game slot number you want to use. - You may also want to disable GameObject in the trigger so that it will not re-trigger.

Auto-save and load Mobile games are usually automatically saved when the player closes the game, and automatically loaded when the player restarts the game. To add this behavior to your game, add an auto-save loading component to the save system:

  • 1. Check Load when starting, load the saved game (if it exists) when starting, check Save when exiting, and save the game when exiting.
  • 2. When the player pauses/minimizes the game, check Save On Pause to save the game. This way, if the player pauses the application and kills it, the game will be saved correctly instead of exiting normally in the application itself.
  • 3. When the application loses focus, check Save On Lose Focus to save the game.

Change the scene

Use the LoadLevel() sequencer command

To use the dialog system to perceive changes to the scene, use the LoadLevel() sequencer command. Or, use SaveSystem.LoadScene() in C#, or connect UnityEvents to SaveSystemMethods.LoadScene.

Scene transition management To play the animation and/or display the loading scene while loading the next actual scene, add a standard scene transition manager to your save system:

If there is a scene transition manager, the saving system will:

  • 1. Set the trigger of the animator to leave the scene transition (if specified).
  • 2. Load the loading scene (if specified).
  • 3. Asynchronously load the next actual scene.
  • 4. After the actual scene is loaded, set the trigger to enter the scene transition (if specified).

Generate object

The dialogue system has a generated object manager that can track objects instantiated into the scene at runtime and include them in the saved game. When you load a game, it will re-instantiate the object.

This is an overview of the configuration process:

  • 1. Add the generated object component to the object preset.
  • 2. Add the generated object manager to the scene and assign object presets to it.

Create a generated object prefab Add the derived object component to the prefab component to be instantiated. Repeat all the items that can be instantiated in the game scene you want to save. Create a Derived Object Manager Create an empty GameObject and add a Derived Object Manager component as shown below. Each scene should have its own derived object manager.

Add all the derived object prefabricated blocks that can be created in the scene to the derived object prefabricated block list. If the prefab component is missing from the list, the derived object manager will not be able to re-derive it when loading the game or returning to the scene. In the example screenshot above, a pre-made component named "pickup_sniper_" is added to the list.

Overview flow chart of the preservation system

The following figure outlines the working principle of the preservation system and the dialogue system:

The loading process is from bottom to top. When changing the scene, the whole process is the same except that the saved game data memory is not used. The saving system just saves the saved data in the memory and applies it to the newly loaded scene. The save system performs the following steps when changing the scene:

  • 1. Tell all the saver components in the current scene to save their state.
  • 2. Tell all protector components that they will be uninstalled, so if they update a counter when destroyed, they should ignore it this time.
  • 3. If there is a scene transition manager, play the "leave current scene" transition (for example, fade out or load the loading screen scene).
  • 4. Load the next scene asynchronously.
  • 5. If there is a scene transition manager, play the "enter new scene" transition (for example, fade in).
  • 6. Tell all the saver components in the new scene to update their status from the saved data.

9. Localization

The dialogue system supports the language localization of the dialogue database and provides common text tables. When you change the language from the default setting, the dialogue system will use the text in the field containing the localized version of the specified language. The dialogue system supports I2 positioning of Inter-Illusion. If you use I2 localization, you may want to use the I2 localization support of the dialogue system.

Language code

For each localized language, you will use a language code. The code is up to you, but a good choice is the ISO 639-1 standard: en.wikipedia.org/wiki/List_o...

Example language codes are: Example language codes are as follows:

Code codeLanguage
esSpanish
ruRussian
fr-CAFrench (Canadian) French (Canadian)

Localizable dialog database fields

By adding spaces and language codes to the field names, all fields are localizable. The only exception is the dialog text field. For dialog text, the language code is used alone. Set the type of localized field to localized. The following fields are common fields to be localized. If no localized field name is defined for the current language, it will use the default field. Common localized dialog input fields For each language LN, the name of the dialog input field is:

Default FieldLocalized FieldExample
Dialogue TextLNes
Menu TextMenu Text LNMenu Text es
SequenceSequence LNSequence es
Response Menu SequenceResponse Menu Sequence LNResponse Menu Sequence es

Explore the field For each language LN, the name of the task field is:

Default FieldLocalized FieldExample
NameName LNName es
DescriptionDescription LNDescription es
Success DescriptionSuccess Description LNSuccess Description es
Failure DescriptionFailure Description LNFailure Description es
Entry #Entry # LNEntry 3 es

In Lua code, you can use the GetLocalizedText() function to get the localized version of the field, which is very useful when entering scripts or conditional fields in a dialog or using [Lua (code)] tags.

How to localize in the dialog editor

The easiest way to use the dialog editor for localization is to add localization fields to the template on the template tab. This way, when you add them, they will be automatically added to the asset. Follow the instructions below to add localization to the conversation database. How to localize the dialogue These steps demonstrate how to add Spanish (es) and Russian (ru) to the dialogue.

  • 1. Expand the Dialogue Entries dialogue record foldout. foldout on the "template" tab.

Click the + on the same line as the title of the conversation entry to add a field. In the title, enter the language code. Set Type Localization

Select Menu Apply Template to Assets to apply the changes to all existing dialog items.

  • On the Conversations tab, check the conversation entry node.

Add the translation to the localization field:

How to localize tasks These steps demonstrate how to add Spanish (es) and Russian (ru) to tasks.

  • 1. Expand the Quests task foldout. foldout on the "template" tab.

Click + on the same line as the task title to add a field. Follow the Title with a space and language code. Set Type to Localization

  • On the Tasks tab, check a task.

Add your translation to the task:

Conversation editor localization export/import folding

Import format localization

10. Scripting

Overview of the source code

Namespaces Namespace All dialogue system source code is contained in the namespace PixelCrushers.DialogueSystem. namespace. The source code of the PixelCrushers public library is in the PixelCrushers namespace. Language.Lua is included in the namespace. Code overview : The dialogue system adopts a model-view-controller (MVC) architecture: MVC| Description -|-|- Model Model| The dialogue database, Lua and the state of the active dialogue. View View | Dialogue UI and cutscenes sequencer. Controller Controller | Mediation between model and view.

commonly used ways

DialogueManager Class PixelCrushers.DialogueSystem.DialogueManager.Bark:

DialogueManager.Bark( "Converation With Bark Lines" , barker.transform); Copy code

PixelCrushers.DialogueSystem.DialogueManager.BarkString:

DialogueManager.BarkString( "I'm barking this text." , barker.transform); Copy code

PixelCrushers.DialogueSystem.DialogueManager.GetLocalizedText:

DialogueManager.SetLanguage ( "fr" ); String frenchForCheese = DialogueManager.GetLocalizedText ( "Cheese" ); duplicated code

PixelCrushers.DialogueSystem.DialogueManager.PlaySequence:

DialogueManager.PlaySequence( "Fade(in,2); Audio(Tada)@2" ); Copy code

PixelCrushers.DialogueSystem.DialogueManager.SendUpdateTracker:

DialogueManager.SendUpdateTracker (); .//Manually Refresh Quest Tracker & Quest log window Displays the HUD duplicated code

PixelCrushers.DialogueSystem.DialogueManager.ShowAlert:

DialogueManager.ShowAlert( "This is an alert." ); Copy code

PixelCrushers.DialogueSystem.DialogueManager.StartConversation:

DialogueManager.StartConversation( "Some Conversation" , actor.transform, conversant.transform); Copy code

PixelCrushers.DialogueSystem.DialogueManager.StopConversation:

DialogueManager.StopConversation(); Copy code

DialogueLua Class

PixelCrushers.DialogueSystem.DialogueLua.GetVariable:

string s = DialogueLua.GetVariable( "favoriteColor" ).asString; Copy code

PixelCrushers.DialogueSystem.DialogueLua.SetVariable:

DialogueLua.SetVariable( "favoriteColor" , "blue" ); Copy code

QuestLog Class

PixelCrushers.DialogueSystem.QuestLog.GetQuestState:

QuestState state = QuestLog.GetQuestState( "The Holy Grail" ); Copy code

PixelCrushers.DialogueSystem.QuestLog.SetQuestState:

QuestLog.SetQuestState( "The Holy Grail" , QuestState.Active); Copy code

PixelCrushers.DialogueSystem.QuestLog.GetAllQuests:

String [] = Quests QuestLog.GetAllQuests () to copy the code

SaveSystem Class

PixelCrushers.SaveSystem.SaveToSlot:

SaveSystem.SaveToSlot( 1 ); Copy code

PixelCrushers.SaveSystem.LoadFromSlot:

SaveSystem.LoadFromSlot( 1 ); Copy code

PixelCrushers.SaveSystem.LoadScene:

SaveSystem.LoadScene ( "Tavern @ Entryway" ); .//the Load Tavern SCENE, to position the Move Player of Entryway GameObject copy the code

Dialogue System Attributes

ConversationPopup Attribute ConversationPopup attribute Use the [ConversationPopup] attribute to convert a string into a conversation popup. It has an optional bool parameter to display the database selection field.

using UnityEngine; using PixelCrushers.DialogueSystem; public class MyClass : MonoBehaviour { [ ConversationPopup ] public string conversation; //Shown without database selection field. [ ConversationPopup(true) ] public string conversation2; //Shown WITH database selection field. } Copy code

QuestPopup Attribute Use the [QuestPopup] attribute in your class definition to convert a string into a quest popup. It has an optional bool parameter to display the database selection field.

using UnityEngine; using PixelCrushers.DialogueSystem; public class MyClass : MonoBehaviour { [ QuestPopup ] public string questName; //Shown without database selection field. [ QuestPopup(true) ] public string questName2; //Shown WITH a database selection field. } Copy code

QuestEntryPopup Attribute QuestEntryPopup attribute Use the [QuestEntryPopup] attribute in your class definition to convert an int type into a task entry popup. Note: This attribute will only work when there is a string variable named'quest','questTitle','questName','quest','questTitle' or'questName' in your script. This is how the task entry pop-up window knows which task entry is displayed.

using UnityEngine; using PixelCrushers.DialogueSystem; public class MyClass : MonoBehaviour { [ QuestPopup ] public string questName; [ QuestEntryPopup) ] public string questName2; //Shows a popup with the entries defined in the quest named by questName. } Copy code

11. Import & Export

The dialogue system can import and export several formats:

Import format

  • articy:draft
  • Aurora Toolset
  • Chat Mapper
  • CSV
  • Ink
  • TalkIt
  • Twine
  • Importing Your Own Formats

Export format

  • Export XML to chat mapper
  • Export to comma separated value (CSV)
  • Export voice-over script
  • Export language text Text

Import your own format

. To import a different format, please copy Templates Scripts ConverterWindowTemplate.cs

Export to other formats

The database tab of the dialog editor has an export folder that allows you to export dialog database data in these formats:

  • XML
  • CSV
  • Voiceover Script
  • Text

12. Component reference

Always Face Camera

Component> Pixel Crushers> Dialogue System> Actor> Always Face Camera Always face the camera so that the game object always faces the main camera.

Attributes

AttributesFeatures
YAxisIt can only be rotated on the y-axis.
Rotate 180If the object is backward-facing, check it.

Bark Group Member

Component> Pixel Crushers> Dialogue System> Actor> Bark Group Member The dialog group member configures GameObject as a member of the dialog group. When one member of a group has a conversation, other members will hide any active conversations

Attributes

AttributesFeatures
Group IdString or Lua expression specifying the group
Evaluate Id Every BarkCheck to re-evaluate the member ID.
Forced Hide DelayWhen hiding an active conversation, wait the amount of time before actually hiding it.
#### Bark On Idle
Component> Pixel Crushers> Dialogue System> Trigger> Bark On Idle
Talk when you are free, and automatically talk once every certain period of time.

Cinemachine Priority On Dialogue Event

Component> Pixel Crushers> Dialogue System> Trigger> On Dialogue Event> Cinemachine Priority On Dialogue Event When a dialogue event occurs, set the priority of the Cinemachine virtual camera.

Condition Observer

Component> Pixel Crushers> Dialogue System> Trigger> Condition Observer The condition observer checks the condition at a regular frequency and runs the operation when the condition is true.

Conversation Logger

Component> Pixel Crushers> Dialogue System> Misc> Conversation Logger Logs conversation activities to the console.

Default Camera Angle

Component> Pixel Crushers> Dialogue System> Actor> Default Camera Angle Set the default camera angle of the actor.

Dialogue Actor

Component> Pixel Crushers> Dialogue System> Actor> Dialogue Actor is an optional component that allows you to associate a GameObject with an actor and configure how it is displayed in UIs.

Dialogue System Events

Component> Pixel Crushers> Dialogue System> Miscellaneous> Dialogue System Events unified display of dialogue system events.

Dialogue System Controller

Component> Pixel Crushers> Dialogue System> Misc> Dialogue System Controller This is the main dialogue system component, which is described in detail in the Dialogue Manager section.

Dialogue System Trigger

Component> Pixel Crushers Dialogue System> Trigger> Dialogue System Trigger When a trigger event occurs, the dialog system trigger component can perform many dialog system operations.

Extra Databases

Component> Pixel Crushers> Dialogue System> Misc> Extra Databases Add and delete additional databases in the runtime environment.

Increment On Destroy

Component> Pixel Crushers> Dialogue System> Actor> Increment On Destroy When the game object is destroyed or disabled, the destruction increment of the Lua variable.

Lua Console

The Lua console provides an in-game interface where you can run Lua commands.

Override Dialogue UI

Component> Pixel Crushers> Dialogue System> UI> Override> Override Dialogue UI Override the dialogue UI of the dialogue manager, used for dialogues involving GameObjects.

Override Display Settings

Component> Pixel Crushers> Dialogue System> UI> Override> Override Display Settings Override the dialog manager's display settings for dialogs involving this game object.

Proximity Selector

Component> Pixel Crushers> Dialogue System> Actor> Player> Proximity Selector The proximity selector provides players with an interface to target "usables" and send them an "OnUse" message by entering their trigger area.

Range Trigger

Component> Pixel Crushers> Dialogue System> Actor> Range Trigger The distance trigger only activates game objects and/or components when the player is in the trigger area.

Selector

Component> Pixel Crushers> Dialogue System> Actor> Player> Selector The selector provides an interface for the player to locate available components and send them OnUse messages.

Selector Use Standard UI Elements

Component> Pixel Crushers> Dialogue System> UI> Standard UI> Selection> Selector Use Standard UI Elements Modify the selector or approach the selector to use standard UI selector elements.

Sequencer Shortcuts

Component> Pixel Crushers> Dialogue System> Misc> Sequencer Shortcuts defines aliases for sequencer commands.

Standard Bark UI

Component> Pixel Crushers> Dialogue System> UI> Standard UI> Bark> Standard Bark UI Use the standard UI system of the dialogue system to display the dialogue.

Standard Dialogue UI

Component> Pixel Crushers> Dialogue System> UI> Standard UI> Dialogue> Standard Dialogue UI Use the standard UI system of the dialogue system to manage the dialogue UI.

Standard UI Menu Panel

Component> Pixel Crushers> Dialogue System> UI> Standard UI> Dialogue> Standard UI Menu Panel is placed on the menu panel that will be used by the standard dialog UI.

Standard UI Quest Log Window

Component> Pixel Crushers> Dialogue System> UI> Standard UI> Quest> Standard UI Quest Log Window Use the standard UI system of the dialogue system to manage a task log window.

Standard UI Quest Tracker

Component> Pixel Crushers> Dialogue System> UI> Standard UI> Quest> Standard UI Quest Tracker uses the standard UI system of the dialogue system to manage a task tracking interface.

Standard UI Subtitle Panel

Component> Pixel Crushers> Dialogue System> UI> Standard UI> Dialogue> Standard UI Subtitle Panel is placed on the subtitle panel that will be used by the standard dialogue UI.

Timeline Trigger

Component> Pixel Crushers> Dialogue System> Trigger> Timeline Trigger Trigger the timeline (playable controller) when the specified event occurs.

Usable

Component> Pixel Crushers> Dialogue System> Actor> Usable Specifies that the GameObject is available-that is, the player can aim at it and send an OnUse message.

4. case demonstration

Case 1: Simple dialogue

Steps: 1. Step 1. Create a new scene (File New Scene).

Step 2. Drag the prefab Dialogue Manager into the scene:

Step 3. To create a dialog database, click Create:

Step 4. After specifying the path and name for the database, open the "Dialog Editor" window again:

Step 5. Click the Conversations tab and click the "+" button to add a new conversation.

Step 6. Create two new dialog nodes

Step 7. In the Inspector panel of the node, set Dialogue Text to "Hello." and "Goodbye."

Step 8. Create an empty game object and rename it to "Player", create a Cube named NPC and rename the empty game object.

Step 9. Click on NPC. Add a dialog system trigger:

Step 10. Click Add Action and select Start Conversation:

Step 11. From the Conversation drop-down, specify the Conversation field as New Conversation 1, and assign Player to Conversation Actor and NPC to Conversation Conversant.

Step 12. Finally, set Trigger to On Start. This tells the dialog system trigger to perform its action at the beginning of the scene.

Step 13, now start your first conversation.

Step 14. Now join the interaction. Click on the NPC and find the Dialogue System Trigger component. Set Trigger to On Use. The dialog system trigger performs its action when receiving an OnUse message

Step 15. Add Usable component to NPC. This is an interactive component, indicating that the maximum distance that an NPC can be clicked is 30

Step 16. Click on the Player object and add a Selector component. Set Select At to Mouse Position:

Step 17. Now start the scene again. Place the mouse on the cube so that you can see the following yellow message:

This means that the player's selector component has detected the available components of the NPC. Now press the space bar or the right mouse button.

The Selector component will send an OnUse message to the NPC, and the NPC's dialogue system trigger will respond by starting the session.

Step 18. To control the Selector component to remain active during the session, add a Dialogue System Events component:

Source project: download.csdn.net/download/q7...

Case 2: Classic Dialogue in "Kung Fu"

Step 1. Create a dialogue database and enter the lines

Step 2. Find the Dialogue Manager, Player, Private Hart, and Room prefabs in the project, and drag them into the scene:

Step 3. Specify the dialog database to your newly created database Player:

Private Hart:

Step 4. Change the dialogue skin of Dialogue System:

Just find this prefab and drag it into the card slot:

Basic Standard UI Selector Elements.prefab

Step 5. Run it and try it

Source project download:

github.com/764424567/D...