Recommended reading

  • CSDN home page
  • GitHub open source address
  • Unity3D plug-in sharing
  • Jane’s address book
  • My personal blog
  • QQ group: 1040082875

One, foreword

Dialogue System is a branching unified conversational System. It does not require any scripts, but it is designed to be easily extended by programmers.

The Unity dialog system lets you:

  • Write interactive dialogues with branching logic.
  • Displays sessions in a flexible, fully customizable UI system.
  • Define the tasks/missions the player will complete.
  • Play shot sequences such as camera clips and audio.
  • Save and load the game, and persist the data as the scene changes.
  • Use localization to display text and play clipping scenes in different languages.
  • Import and export various formats, such as Draft, Chat Mapper, and CSV.

Effect:

Two, download address

Download.csdn.net/download/q7…

Third, the body

1, start

Set up the

If your project uses Unity5.x, you must first change to force text serialization

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

The next step

⑴ Demonstration Scenario

Demo scenePlay it in Plugins ► Pixel Crushers ► Dialogue System ► Demo and see how the Dialogue System works

How to play

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

Demo Tasks You can do this in the demo scenario:

  • Get launch code (mission) : Talk to Private Hart to get this mission. It involves finding a password in the next room and interacting with the computer.
  • Enemy attack (quest) : Complete this quest by talking to an NPC in the next room. It demonstrates how to set up a counter based task, in this case a kill task.
  • Change scene Interact with the door to change the scene. This demonstrates how to preserve data in the context of a scenario change.
  • Save mini-game use the “pause” menu to save and load the game.
The essay outline

The dialogue system consists of the following main parts:

  • Dialogue database: Contains conversations, tasks, and variables.
  • Dialog editor: Edit the dialog database. You can also import and export third-party formats.
  • Dialog manager: Manages dialog system activities at run time. Provide prefab.
  • Dialog UI: Displays interactive dialogues, alert messages, task logs, and so on.
  • Interactive system: Triggers activities at run time, such as starting a session.

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

The dialog database contains the design-time content, as well as the fields edited in the Unity editor. At run time, the dialog system treats the dialog database as a read-only database; It loads the dialog database field into a place where the value can be changed during the game.

Dialog editor

Dialog manager

The dialog manager is a GameObject in your scenario that coordinates all the dialog system activities and saves the runtime data of the dialog system.

Dialogue UI

The dialog system uses the following UI:

  • Dialog UI: Run interactive dialogues and alert messages. (As shown above)
  • Quest Log window: Displays the player’s active missions and completed missions.
  • Task tracker HUD: Displays the tracking information of active tasks.

Interactive systems

The dialog system provides components to interact with GameObjects and perform actions such as starting the dialog and updating the status of the task.

localization

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

Extended dialog system

While the default features of the dialog system are powerful and flexible, you can also create your own logical functions, crop scene actions, UI types, and so on. This can be written in a script.

⑶ Quick start

This section jumps directly to using the dialog system to create and run a session. You will learn how to:

  • Create a dialog database and write the dialog.
  • Set up the dialog management GameObject.
  • Start a conversation.
  • Interact with objects.
  • Disable player controls for the duration of the conversation.

Steps:

Step 1. Create a New Scene (File → New Scene).

Step 2: Drag the prefab Assets ► Plugins ► Pixel Crushers ► Dialogue System ► Prefabs ► Dialogue Manager

Step 3. This GameObject already points to a basic dialog UI, we need to Create a dialog database, let’s 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 on the gray Node (” hello. “), select Create Child Node to Create a Child Node, and type “Good Bye.”
  • The grey nodes are what NPCS say, and the blue nodes are what players say. Your conversation should go as follows

Step 6. Create an Empty GameObject for the player (GameObject → Create Empty) and a Cube for the NPC(GameObject → 3D Object → Cube). Rename the empty gameobject 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 the NPC. Add a dialog system trigger:

Step 8. Click Add Action and select Start Conversation:

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

Step 10. Finally, set the Trigger to On Start. This tells the dialog system that the trigger performs its actions at the start of the scene.

Step 11: Now have your first conversation! The dialog system displays the NPC line (” Hello. “). This is followed by the Player Response menu, which contains an option (” Goodbye. “). It uses the basic standard dialog UI, which is a generic template that you can later customize to see whatever you want.

Next, we’ll use the interactive system to start the conversation.

Step 12. Set the Trigger to On Use. This tells the conversational system that the trigger performs its actions when it receives an OnUse message, usually from an interactive component on the player.

Step 13. Add the Usable component. This tells the player’s interactive component that the maximum distance from which an NPC can be clicked 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 your mouse over the cube to see the following yellow message:

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

The Selector component and the Similar, Proximity Selector, provide methods for triggering activity in the dialog system. They are customizable. You can configure them to choose a number of different methods, rather than just using a mouse cursor. Their use is also not mandatory. If you wish, you can use your own interactive system or C# code to run the dialog system trigger.

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

Summary This quick start demonstrates how to:

  • Create a dialog database and write the dialog.
  • Set up the dialog management GameObject.
  • Start a conversation.
  • Interact with objects.
  • Disable player controls for the duration of the conversation.

2. Dialog editor

⑴ Dialogue database

The dialog database is an asset file. To create a dialog database, do the following:

  • Click the Create button in the dialog management.
  • Or select Assets → Create → Pixel Crushers → Dialogue System → Dialogue Database

The dialog database contains the following categories:

category describe
Database Database Set the description, author, and version, as well as the database scope
Role of Actors Session participants (players, NPCS, interactive objects)
Quests Task definition
Locations where The location information
The Variables Variables User-defined variables to judge the conversation decision
Conversations to talk dialogue

Each category is described in detail below

The dialog edit window

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

(3) the Database Database

The Database Properties:

  • Author: the Author
  • Version: Version
  • Description: describe
  • Global User Script: Global User Script that loads Lua code for database Settings at run time
  • Emphasis Settings: Emphasis setting. You can highlight and set the value of the color

Global Search & Replace: Global Search and 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 you are currently editing. Export Database: Allows you to Export the dialog Database into various formats such as Voiceover scripts and CSV(spreadsheet). Foldout allows you to Export localized CSV files in a simpler format than exporting database Foldout. Foldout contains Settings such as where and how frequently to automatically back up a database.

(4) role of Actors

The Actors TAB defines the dialog participants. You can specify the name of the participant (as well as an optional display name to use in the UI), an optional portrait image, and so on. Portrait images can be texture assets or Sprites. If you are using Sprites for a character, do not assign a value to the portrait texture. Also, if you’re using textures, don’t assign Sprites.

(Quests/Items

The Task/Project TAB defines tasks and projects. A project is just a record of data that you can use for your own purposes. The dialog system does nothing special for entries. Tasks are used by the task system, as detailed in the tasks section. Use this TAB to define tasks and optional task items (subtasks). Your task text can include tag tags. The state is the start state of the task. This value is not updated in real time at run time; Instead, view the real-time status of the task on the watch TAB. If you want the task to appear in the task tracking screen, check traceable and track at the start (tracking will be enabled as soon as the task is activated).

[6] Locations where

Location is just a data record. The dialog system doesn’t do anything special with the location.

Once the Variables Variables

Variables are values that you can set and check in the game. Use them to track information, such as decisions made by the player, the number of goals achieved or lost in the mission, and so on. The Conversations TAB and the Dialog system component provide dropdown menus to select variables and examine or set them.

The dialog system will automatically create and set four variables at the beginning of the dialog. You don’t have to add them to the database, but you can add them if you want to refer to them conveniently in a drop-down menu in a conversation.

  • Actor: The display name of the main Actor (usually the player) in the conversation.
  • Conversant: Display name of the primary interlocutor (usually an NPC) of the conversation.
  • ActorIndex: Index of Actor[] table of actors, which provides optional low-level Lua code.
  • ConversantIndex: Actor[] puts the ConversantIndex into the table.

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

Being Conversations dialogue

This is the heart of the dialogue editor. You can use the node editor (shown above) to create, edit, and delete conversations. During run time, this TAB displays a live view of the current conversation.

Node editor

operation steps
Create new conversation Click “+” to the right of the dialog title drop – down box.
Edit Conversation Properties Edit session properties Click on the blank canvas area. Display Settings for setting the title, primary actor, and override dialog manager.
Add/ Delete node Adds or deletes a node Right-click on node’s context menu. (When adding child nodes, hold down the Shift key and use the same actor assignment instead of swapping them.)
Edit Node Edit node Click the node.
Edit Link arrow Edit Link arrow Click the link arrow.
Change display Settings Changes display Settings Use uses the Menu Menu in the upper right corner.

The inspector view of the node

operation steps
ID Content ID
The Title Title The optional text is for reference only. Not shown to the player.
The Description described The optional text is for reference only. Not shown to the player.
The Actor role The character who says the line.
Conversant conversation The speaker speaks to the character (audience).
Group, a Group If checked, it is marked as a pass-through node for grouping child nodes.
Menu Text Menu Text Text displayed in the player response menu, such as a short explanation of the conversation text. If this parameter is empty, the dialog text is default.
Dialogue Text Text shows captions. If empty, the default is menu text. Note: You can also double-click a node to enter the dialog text directly on that node.
The Sequence Sequence The cutscene that plays when the character says the line. If empty, the dialog manager’s default sequence is used.
Response Menu Sequence Response Menu Sequence Optional sequences play in the background, while the response menu is visible. If the player selects from the Response menu while playing the response menu sequence, the response menu sequence ends and the next sequence of dialog items begins on the same frame.
Conditions of the Conditions The condition must be true to allow the player to say or display the line in the response menu.
False Condition Action Response to an error Condition What to do when things aren’t right.
Script Script The operation to run when the node is invoked.
OnExecute() Run UnityEvent when this node is called.
The Links To link Use the drop-down menu to manually set the links, adjust their priority, and adjust their order.

Conditions of the Conditions

You can add a Lua expression to a condition field by using a point-and-click drop-down menu or manually typing to allow the conversation to use the input only if the Lua expression is true. For example, suppose you only want the NPC to say one line of dialogue when the player visits Paris. You can define a variable “VisitedParis” with an initial value of false. Set the variable to true when the player visits Paris. Then add a condition to the NPC’s dialog entry:

  • Dialogue Text: “So, what did you think of Paris?” “So, what do you think of Paris?”
  • Condition: Variable[“VisitedParis”] == true

Evaluate the conditions one level ahead of time

The dialog system evaluates the link at an additional level before the conversation. It must do this in order to properly handle certain continue button modes. This means that if you set a value on one node (for example, node), then you can’t check it on the next node (node B) because the dialog system will have checked node B before running the condition of the node. Instead, you need to postpone the evaluated condition with an empty interval node alone. To demonstrate this, we’ll use a coin-flipping dialog example:

In the example above, the “coin toss” node randomly sets the variable x to either 1 or 2. We can’t immediately use the two condition nodes (” heads “and” tails “) for tracking because the conversation system evaluates one level ahead of time — meaning that it has tested the “heads” and “tails” conditions before the “coin flip” node runs.

To solve this problem, we added an intermediate node to the conversation, set the title to “Delayed evaluation” to remind ourselves of its purpose, and left the conversation text blank. We then set the sequence to None() so that it immediately goes to 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 None().

It may also be helpful to temporarily set the debug level of the dialog manager to Info when working with conditions. This adds a lot of information to the console window. If you read carefully, you’ll notice that the following lines are similar:

Dialogue System: Lua(x = math.random(2)) Dialogue System: Referee says 'Flipping coin... ' Dialogue System: Block on False Link (Referee): ID=5:3 'Heads! ' Condition='x == 1' Dialogue System: Add Link (Referee): ID=5:4 'Tails! ' (True) Dialogue System: Referee says 'Tails! ' 
Copy the code

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

OnExecute() UnityEvent

The event collapse consists of 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 scenario, you cannot assign the scenario object. Instead, you must allocate an asset file, such as a Prefab or ScriptableObject. Note :UnityEvents is not supported by the database export feature or third-party format importers.

In the following example, we’ll create a ScriptableObject asset that provides methods to play audio clips. We then assign this method to the OnExecute() event of the dialog entry.

First, create a new c# script called TestScriptableObject that 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 the code

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

You may want to move the assets into a folder called Resources. In this way, it will be included in the build. In some versions of Unity, the platform will strip assets it doesn’t think it needs. This usually happens in script object assets, which are not referenced in any scenario.

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

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

Outline Editor

You can also edit the dialogue 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

‘levies Templates Templates

Use the Templates TAB to change the default fields added to new roles, tasks, dialog entries, and so on. You can also change the color used in the outline mode of the dialog TAB. The upper-right menu allows you to save and load the template Settings, populate 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 check the master checkbox, which tells the dialog editor to show it in the master inspector section of the actor, not just in all fields.

⑽ Watches watch

At run time, a Watches TAB replaces the Templates TAB. In this TAB, you can view the runtime values of variables, tasks, and any Lua expression. You can also run Lua expressions using the code bar at the bottom of the window.

(11) Use multiple databases

It is usually much easier to use a single conversation database. However, the dialog system supports multiple databases. You need more management of multiple databases to keep track of them and load and pull memory when appropriate, but they are useful for breaking down your content, both for organization and for reducing the amount of content loaded into memory at any given time.

Deciding Between Single Or Multiple Databases There are some criteria to determine whether to use one database Or Multiple Databases:

  • A conversation database containing 1000 conversations of average length requires about 15 MB of memory, equivalent to several texture files.
  • If you’re making a board game, 15 MB shouldn’t be a problem. In this case, the only reason to use multiple databases is for the benefit of your organization.
  • If you’re building a very low-end mobile device, 15 MB may be too much, but ultimately it depends on your specifications and requirements.
  • A single database has a larger memory budget than you’d like to use, or your database has many different elements that you need to organize and break apart.

Sync Assets From Another Database

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

Unique ID Tool Specifies the Unique ID of a Tool

If you are using only one dialog database, you can skip this page. Internally, each element in the dialog database (actor, item, conversation, and so on) has an ID number. Within a single database, these ids are typically unique for each type of element. However, an ID used in one database may also be used in another database. If two databases are loaded at run time, the ids will conflict. The conversational system will not know which asset you are referring to with the given ID. To prevent this, use the Unique ID Tool :Tools → Pixel Crushers → Dialogue System → Tools → Unique ID Tool. Simply add the database whose ID you want to ensure is unique, and click Process. If you select detailed logging, the tool records all ID number changes in the console.

3. Dialog manager

Dialog manager prefab

The dialog manager coordinates the runtime activities and maintains the Lua environment that contains the runtime data of the dialog system. Add a dialog Manager and drag the premade Assets ► Plugins ► Pixel Crushers ► Dialogue System ► Prefabs ► Dialogue Manager

The default Settings for the dialog manager keep it constant as the scene changes and ensure that only one copy exists in the scene. You will usually use a dialog manager that is added to your main menu scene. You can place other dialog 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 dialog manager in the main scene will execute and destroy the “Test” dialog manager in your location scene.

Dialogue System Controller

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

The display Settings section contains the following subsections:

  • Localization Settings: Controls how language localization is handled.
  • Captioning Settings: Controls how the dialog UI displays captioning.
  • Camera and cutscene Settings: Controls how the cutscene sequencer works.
  • Input Settings: Controls how the player response menu works in the conversation.
  • Warning Settings: Controls how 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 to save when the scene changes.Other Settings Other Settings

The Other Settings section contains other Settings. It is worth noting that:

  • Instantiate database: Load a copy of the dialog database instead of using the asset directly in the Unity editor’s Playmode.
  • By default, the dialog system runs Realtime Mode, if you want to use the Time scale, set GamePlay Mode
  • Debug level: Set the dialog system log level in the Unity editor’s console and the player log file in the build. This is very convenient for tracking through conversational system activity.

Instantiate Prefabs: Instantiate the basic UI prefab into the dialog manager’s canvas. These include selector elements (see triggers and interactions), as well as the task tracking HUD and task logging window (see Tasks). You can assign different prefabricated components to customize the look of the game.

The Input Device Manager detects switches between mouse, joystick, and keyboard controls, and helps the UI know when to auto-focus the UI buttons (in joystick and keyboard mode) and when not to focus the UI buttons (in mouse mode).

4. Triggering and interaction

How do we interact in this video

Dialogue System Trigger Dialogue System Trigger

The dialog system trigger component has three main parts:

  • Trigger: Causes an event to be triggered by the dialog system.
  • Conditions: The dialog system must be true when it triggers the execution of its actions.
  • Actions: What a trigger should do, such as starting a conversation or setting the status of a task.

Trigger can set the Trigger drop down to these values:

The Trigger is triggered describe
On Use The 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 a UnityEvent or script.
On the first day of the year The component starts (for example, when the scenario starts).
On Enable Indicates whether to Enable The component is enabled.
On Disable Disable The component is disabled. Procedure
On Destroy The component is broken.
On Trigger Enter Indicates the Trigger input The component is enabled.
On Enable Indicates whether to Enable This component receives 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 Players with specific Tags (e.g.
On Trigger Exit Indicates that an Exit is triggered The component receives an OnTriggerExit message.
On Collision Enter Description The component received an OnCollisionEnter message.
On Collision Exit The component received an OnCollisionExit message. Procedure
On Bark Start GameObject starts playing Bark (one-off dialogue).
It ends at the Bark The GameObject finished the game against Bark.
On Conversation Start The GameObject is just the main player in the conversation.
At the End of the Conversation GameObject just finished the conversation.
On Sequence Start Indicates the Start of the Sequence The GameObject simply starts out as the main player in the cutscene sequence. This event is not called Subtitle Settings → Inform Sequence Start And End unless you have checked the dialog Sequence in the dialog manager
On Sequence End Just finished a sequence.

Conditions of the Conditions

Conditions in the describe
The Lua Conditions are as follows Lua expressions, such as checking the value of a variable.
Quest Conditions It needs to be explored.
Accepted Tags Accepted Tags For OnCollision and OnTrigger events, another GameObject must have one of these tags. If the accepted tag is empty, all gameobjects are allowed.
Accepted GameObjects Accepts objects For OnCollision and OnTrigger events, another GameObject must be in this list. If the accepted GameObject is empty, then all gameObjects are allowed.

The Action Action

The Action Action describe
Set Quest State Sets the task State Set the task and/or the task entry state
Run Lua Code Runs Lua Code Run the Lua expression.
Play Sequence Play Sequence Play a cutscene
Show Alert Shows alerts Display warning messages through the dialog UI.
Send Messages Send Messages The message is sent to the target using Unity’s SendMessage() method.
Start a Conversation Start a conversation.
Set GameObjects Active/Inactive Set GameObjects Active/Inactive Work on the entire game object.
Set Components Enabled/Disabled Specifies whether to enable or disable Components Specific components that work in the game object.
Set Animator States Sets the animation status Set the animator state on GameObjects. Useful for idle characters when a conversation begins.
OnExecute() UnityEvent Allows you to specify additional operations using UnityEvent.

Selectors & Usables and available

The dialog system provides an optional interaction system for interacting with game objects with available components, such as NPCS. You can add two components to the player:

The Selector Selector

The selector component detects available items by raycasting them from a specified location, such as the mouse position or the center of the screen. When the use button is pressed, it sends an OnUse message to the user.

Proximity Selector

The proximity selector component detects available items on input to the trigger collider. When the use button is pressed, it sends an OnUse message to the user.

When the player aims at an available one and presses the Use key or use button, the selector sends an OnUse(Transition Player) Message to the available game object. The trigger of the dialog system, such as the dialog system trigger, responds to this message. Your own scripts 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 the code

4. Dialog UI

Dialogue UI

This chapter explains how to set up a conversational user interface and a user interface. The dialog system uses the dialog UI to display interactive dialogues and alert messages on the screen. You can customize how each participant appears in the UI by adding a dialog participant component.

Standard Dialogue UI Standard Dialogue UI

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

  • Warning Panel: Displays warning messages.
  • Subtitle Panel: Displays the actor’s dialogue text.
  • Response menu: Displays responses that the player can choose from.
  • Timer: Displays a countdown if the dialog manager is configured as a timed response menu.
  • Text input: Read text input from the player.

All UI elements can be repositioned and adjusted.

The easiest way to do this is to assign a prefab block to the dialog UI field of the dialog manager. Prefabs ► Standard UI Prefabs template

  • Basic: The default UI shown above.
  • Bubble: The character above the cartoon Bubble that displays the subtitle panel and the response menu
  • Focus: The speaker of 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: The traditional visual novel layout with a larger portrait image above the caption/menu box.
  • WRPG: A traditional Western RPG layout with a scrolling dialogue log.

Subtitle Panels & Menu Panels

A standard dialog UI usually has one or more subtitle panels and menu panels. Assigns the subtitle panel to the subtitle panel list. Set the NPC default subtitle panel and PC default subtitle panel, specifying which panels are used by NPCS and players by default. An Actor that has a dialog Actor component can specify a different panel than the default panel. If the open subtitle panel is allowed to be true at the beginning of the conversation, the dialog system will check all the participants in the conversation 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 panels are configured to be open at the start of the dialog, you can bypass this check box by unchecking it. Assigns a menu panel to a menu panel list. Set the default menu panel to the default menu panel. Typically, you will have only one menu panel. In most cases, you will assign a subtitle panel and a menu panel on the same canvas as the dialog UI. However, it is possible to assign panels that are on different canvases.

Subtitle Panel

Menu Panel

The subtitle Panel and the menu Panel can play the Animation when the state changes. To assign animations, add an Animator component to the panel. Specifies an animation controller that has triggers in one or more of the following states. The following list describes the time 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

Scripts are not required in the dialog system. However, the conversation system provides a general purpose scripting language called Lua, which provides a very powerful way to control the conversation flow, check and change task state, and so on. In most cases, you can use a simple one-click menu. The dialogue system uses the data model established by Chat Mapper, another professional dialogue authenting tool commonly used in the industry. Information about all participants, items, locations, variables, and conversations is stored in Lua tables. You can control the conversation by specifying Lua conditions and scripts, usually by using point-and-click menus. For those who are interested, the Chat Mapper manual has more background information on Lua and the tables used by the conversation system in the section titled Writing scripts in Lua.

Where is Lua used in the conversation system

At run time, the conversation system treats your conversation database as read-only. It loads the database values into Lua, where the current values can be checked and changed. You can use Lua in the following areas of the dialog system:

  • Condition and script fields in the dialog entry.
  • The text of the dialog entry and task field within the [Lua (code)] tag (see tag tag).
  • Dialog system trigger
  • In your own scripts, use the Lua and/or DialogueLua classes (see how to use Lua in your c# scripts)
  • The watch TAB in the dialog editor and the Lua console component in the game.

Point-and-Click Lua

In most places where you can manually enter Lua code (if you wish), you can also click on a ‘… Button toggles the field to click mode. In this mode, you can use the drop-down menu without having to enter any code:

Click + to add a new condition or action. Click Restore cancel or apply your selection, this will close the drop-down menu and write Lua code for you:

How to write Lua code

If you prefer to write Lua code directly, you will find that it is similar to c# or UnityScript. For more information about Lua, see www.lua.org.

6. Animation sequences

Sequence and dialog entries

In a dialogue system, each line of dialogue can be bound to a cutscene sequence — for example, playing an animation, an audio file, and/or moving the camera. This sequence is specified in the sequence field of the dialog entry or, if the sequence field of the dialog entry is empty, in the dialog manager’s default sequence. During a conversation, the dialog system displays the dialog text of the dialog entries for the duration of the conversation sequence. For example, if the sequence runs for 5 seconds, the dialog text is displayed as a 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 dialogue, even using external authoritizing programs such as chat Mapper and Articy: Draft. A large library of sequencer commands is already included, and you can easily add your own. The complete list of built-in sequencer commands is in the sequencer command reference. In most cases, you don’t need to do this if you don’t want to enter commands manually. 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 provided Timeline() Sequalizer command.

The Angles of the Camera

When you use the Camera (x) command in sequence, it first checks the camera Angle presets. If it finds a child object with a name that matches x, it uses that child object’s preset offset from the camera Angle. It then positions the camera at the same offset as the character.

Example: The default camera Angle preset has a child component called close-up, which is approximately 2 cells up and 1 cell back. The sequencer commands the camera (close-up) to move the camera up about 2 units and back 1 unit, as shown below:

The default camera Angle preset has another subcomponent called “Medium” that is 2 units up and 2 units back, which makes the camera slightly further away from the character. To add a camera Angle that points to a seated character, you might add another child object that is only 1 unit up and 2 units back. If the dialog system does not find a matching subobject in the camera Angle presets, it looks for a GameObject named X in the scene. If it finds one, it treats it as an absolute camera position. It moves the camera into the same position as the GameObject and rotates it. You can add empty GameObjects to the scene, specifying the absolute camera position.

Default Camera Angles

The default camera Angle prefab contains these angles:

Angle Angle The Description described
The Closeup A front-on head shot
The Closeup Back Back of the head
Closeup Left The Left side of the head
Closeup Right It’s on the Right side of the head
Medium in the middle The Head and torso are stacked in front of the hips
Medium Back The Back of the head and the hips of the torso
Medium Left Left side of head and torso
Medium Right The Right side of head and torso are stacked in front of the hips
Full and complete Front on body
Full Back bakC The Back of the body
Full Left Left side of the body
It’s Full Right I’m on the Right side of the body
Wide width Body with space (farther than Medium shots)
OTS Left OTS to the Left Over the left shoulder
OTS OTS Right Right Over the right shoulder
Down Down Looking down on the subject
Up Up He looked up at the subject

Camera Angle Editor Edits Camera angles

You can use the Camera Angle Editor tool to help you create camera Angle prefabricated components. Using the Camera Angle editor:

  • 1.Select menu item Tools → Pixel Crushers → Dialogue System → Tools → Camera Angle Editor.
  • 2. Theme: Assign a character to 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 Resources, or you can create your own from scratch. If you specify a prefab, you can only edit existing angles. To add a new Angle, you have to click the button to instantiate the prefabricated scene object.
  • 4. Camera Angle: Select camera Angle from the drop down menu. The game view moves to the selected camera Angle. To add a new camera Angle, click “+” next to the popup menu.

Remember to save your new camera Angle set as a prefab or scene object so you can assign it to your dialog manager’s display Settings.

7. Mission system

Quests are usually started and completed by talking to NPCS. The dialogue system provides an integrated mission system that makes it easy to manage tasks during dialogue and play.

Writing Quests

Write tasks using the task/item section of the dialog editor.

Quest Fields

Field The Description described
Name the Name The name of the task in the dialog database. If the Use Display Name is unticked, this Name is also used in UIs. Unchecked, this name is also used in the UI.
Use Display Name Indicates the Display Name Use the Name field. Field in UIs which is different from the Name Name.
Display Name Display Name The Name to be used in the UI if Use Display Name is used.
Use Groups Use group Group tasks in the user interface.
Group, a Group If Use Groups is selected, classify the task into Groups.
State of the State Task start status.
They are Trackable Tasks can be displayed in the on-screen task tracking HUD. Players can toggle tracking and turn it off.
Track On Start Indicates the Start of the Track W When a task is activated, it is immediately displayed in the task tracing interface (tracing is turned on).
The Visible Visible Optional; If true, do not display in the task log window.
Abandonable The player can abort the mission.
Has Entries Subtasks Tasks have subtasks.
The Description described The task description is displayed in the task log window when the task is activated.
Success Description Description of the Success Description that is displayed when the task is in the success state. If blank description is displayed.
Failure Description Failure Description Description that is displayed when the task is in the failed state. If blank, the Description is shown.
Entry # Enter # “If (Has Entries have a description of an item.
Entry # State Enter the start state of the # status entry.

Markup Tags TagsYou 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 LocalizationYou can define localized versions of all text fields, such as name, display name, description, entry #, and so on, in the All Fields section or in the Template TAB. For example, to add a French version of the display name, add the field display name fr.Runtime States Runtime statusThe task/entry section of the dialog editor displays the design-time content of the dialog database, not the runtime state of the task. To see the runtime status during play, use the Watches TAB.Example QuestThis is one of the tasks in the dialog system demonstration scenario:

  • Players can switch the task interface Trackable, Track on Start.
  • There will be a different description after the task is completed (success description).
  • Tag tag to display the current count, which is stored in a variable named enemiesKilled.

Controlling Quests

You can usually use the pointing and clicking Lua wizard to check and set Quests in Conversations. If you want to use the Quest Management Lua function directly, you can summarize it as follows:

Lua Function Lua Function The Description described Example Example
CurrentQuestState(questName) Returns a quest state as “unassigned”, “active”, “success”, or “failure” CurrentQuestState(“Kill 5 Rats”) == “active”
SetQuestState(questName, state) Sets a quest state Sets the task state SetQuestState(“Kill 5 Rats”, “success”)
CurrentQuestEntryState(questName, entryNum) Returns a Quest entry state Returns a quest entry state CurrentQuestEntryState(“Escape”, 2) == “active”
SetQuestEntryState(questName, entryNum, state) Sets a Quest entry state Sets a quest entry state SetQuestEntryState(“Escape”, 2, “success”)

You can use these components to control tasks:

  • Increment On Destroy Increases the destruction counter when killing or collecting a target.
  • Dialogue System Trigger – common action.
  • Condition Observer Monitors a Condition and performs an action when the Condition is true.
  • Timeline Set Quest State Playable – Controls tasks on the Timeline.
  • The general-purpose Trigger Event, Collision Event, Timed Event components are also useful for managing quests. Common trigger event, collision event, and scheduled event components are also useful for administrative tasks.

Quests Controlling Quests in ScriptsThe QuestLog class provides ways to add and remove tasks, get and set their state, and get 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 during the conversation. In most cases, you’ll probably use the point-and-click Lua wizard to set task state during a conversation, so you’ll probably 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 note on table indexes); The QuestLog class will do this for you automatically.Quest State Messages Task status MessagesWhen the task status changes, the dialog system sends an OnQuestStateChange message.Quest Management ExampleIn the example mission above, NPC Sergeant Graves gives the player a kill mission in the dialogue:

In the highlighted node, the script fields are set using the point-and-click Lua wizard. It does two things:

  • Set task activation.
  • Set the alert variable to display the alert message at the end of the conversation.

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

Component’s OnIncrement() event also runs OnUse method’s dialog system trigger on a game object named enemy:

Many tasks

How you manage tasks in a multiplayer game depends a lot on the design of the game. In many cases, you can maintain a dialog 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 task status on the master server to prevent cheating. To do this, override methods are assigned to these delegates:

  • QuestLog.SetQuestStateOverride
  • QuestLog.CurrentQuestStateOverride

In the SetQuestStateOverride method, contact the master server to confirm that the player is allowed to set the state of the request. . If so, call QuestLog DefaultSetQuestState (), it will be set up in the local state of the quest, update the tracker, and notify the listener.

In CurrentQuestStateOverride approach, contact the authority of the master server to make sure the player task status. The use of this method can be more complex than SetQuestStateOverride. Communication with the master server is usually asynchronous; Your override method may not be able to return quest status immediately because it needs to wait for a response from the master server. Instead, your method can return a string reference to an asynchronous operation. Then, the code that calls CurrentQuestState() can wait for the asynchronous operation to complete and retrieve the Quest state from the response, rather than immediately using the return value of the Override method as the Quest state. Task status is often checked and set during the conversation. When using an asynchronous override method that does not return an immediate value, you might want to configure a sequence of dialog entries to wait for a collator message indicating that the asynchronous method has completed. In the dialog item, wait for the collator message using the WaitForMessage() collator command. In the asynchronous method, the sequence.message () method is used to send the sorter message. If the dialog item is configured to wait for a task state (that is, task state). , you have already set up CurrentQuestStateOverride), you can register an additional Lua function, the next entry dialog, you can use the function to return from the master server receives the value.

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

  • QuestLog.SetQuestEntryStateOverride
  • QuestLog.CurrentQuestEntryStateOverride

Task interface

Quest Log Window Task Log Window

The quest log window displays the player’s active quests and details of their completion. The recommended way to set up the task logging window is to use the standard UI task logging window component.

** Standard UI Task Log window ** Standard UI Task Log window manages the UI elements shown in the screenshot above. These elements are:

  • Main panel: Controls switching between displaying active tasks and completing tasks.
  • Select Panel: Displays task titles, optionally included in group folders. Players can switch tracking or select a task to see its details.
  • Details Panel: Displays the details of the currently selected task.

All UI elements can be repositioned and adjusted.

The easiest way to set up the task log window is to use Prefabs ► Standard UI Prefabs ► Basic. This prefab component is assigned to the dialog manager’s instantiated prefab component, which means it will be automatically instantiated 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 quest instructions to tell the player that the NPC has quest information.

Set task instructions:

  • Adds indicating game objects to NPCS. For example, add a Unity UI World Space Canvas with one or more images, such as a question mark to indicate that new quests are available and an exclamation mark to indicate that the NPC has quest updates. In the DemoScene2 scene, NPC Sergeant Graves has a quest indicator canvas.
  • Add a Quest State Indicator to the NPC. This allows you to associate gameObjects (such as world Space Canvas images) with numeric Indicator levels. For Sergeant Graves, the indicators are:

Level 0: Nothing; Level 1: Question mark; Level 2: Exclamation mark; is a punctuation mark or exclamation

  • Add a task status listener component to the NPC. When the task state changes, this component updates the current indicator level of the task state indicator and optionally does other things through UnityEvent(which can be connected in the inspector). To configure the task state listener, add elements to the task state indicator level collapse. Within each element, specify a task state and the level of indicators associated with the task state. The task entry state also has a corresponding fold-out. The highest indication level is always the priority. If your NPCS involve more than one task, you can add multiple task status listeners.

8. Save the system

The conversation system uses Pixel Crushers Common Library’s save system. The Save system component is configured in the demonstration scenario. The dialog manager has a save system component and several components related to save system components:

The demo menu calls the static script method savesystem.savetoslot () to save the game and savesystem.loadFromslot () to load the game.

Save system Settings

  • 1. Add a save system component to the scenario — for example, on the dialog manager in the demo scenario. The Save System component will make the GameObject a persistent singleton, which means that it will still exist after the scene changes, and there is usually only one instance.
  • 2. Add a dialog system protector. This component sends data from the dialog system to the save system.
  • 3. Add a Json data serializer component. This component converts binary saved game data into a savable 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 Player Prefs saved game data store or disk saved game memory component. 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. A game store program that supports disk save in a separate build. If you want to store your game differently, you can add your own implementation of the SavedGameDataStorer class.
  • 5. Optionally add a standard scenario transformation manager. This component can load screen scenes and/or play animations such as fade in and fade out when the scene is changed. In the demo scenario, the transformation manager is configured to fade to black during scenario changes. For more information, see Scenario Transformation Manager.

Save component Settings

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

Component components The Function Function
Active Saver Saves the active/inactive state of the game object. If the GameObject becomes inactive, add this component to the different GameObjects that are guaranteed to be active and assign the target GameObject.
Multi Active Saver r Saves the active/inactive state of multiple game objects.
Animator Saverr Save the state of GameObject’s Animator.
Destructible Saver r When saved, the game object has been destroyed or disabled. The next time the game or scene is loaded, if the GameObject has already been destroyed/disabled, this script will destroy/disable it again. If a prefab is specified, it also produces a broken replacement version.
Enabled Saver r Save the enabled/disabled status of the component. If the GameObject is started inactive, this component is added to the different GameObjects that are guaranteed to be active and the target component is assigned.
Position Saver r Saves the position and rotation of the game object.

Save and load

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

How to save the system

To access the Save system method without scripting, 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 saves are trigger areas that automatically save the game when the player enters. Set a checkpoint save:

  • 1. Create a gameobject and add a trigger collider. (At least one object, the player or trigger, may need a rigidbody to record triggering conflicts.)
  • 2. Add the save system method component.
  • Add a Trigger Event to Trigger the Event component

Set the label mask to the 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 the GameObject in the trigger so it doesn’t refire.

Auto save and loadMobile games usually automatically save when the player closes the game and automatically load when the player restarts. To add this behavior to your game, add an autosave loading component to the save system:

  • 1. Select Load during startup, load the saved game (if any) during startup, select Save when exit, and save the game when exit.
  • 2. Select Save On Pause to Save the game when the player is pausing/minimizing the game. This way, if the player pauses the app and kills it, the game will be saved correctly instead of exiting normally in the app itself.
  • 3. When the app loses Focus, check Save On Lose Focus to Save the game.

Change scenarios

Use the LoadLevel() sequencer command

To use the dialog system to be aware of changing scenarios, use the LoadLevel() collator command. Or, in c # using SaveSystem. LoadScene (), or connect the UnityEvents SaveSystemMethods. LoadScene.

Scenario transition managementTo play the animation, and/or show the loaded scene, while loading the next actual scene, add a standard scene Conversion manager to your save system:

If there is a scenario transformation manager, saving the system will:

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

To generate the object

The dialog system has a generated object manager that tracks the objects instantiated into the scene at run time and includes them in the saved game. When you load a game, it reinstantiates objects.

Here’s an overview of the configuration process:

  • 1. Add the generated object components to the object preset.
  • 2. Add the generated object manager to the scenario and assign object presets to it.

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

Add all derived object prefab blocks that can be created in the scenario to the derived object prefab block list. If the prefab component is missing from the list, the derived object manager will not be able to rederive it when the game is loaded or the scene is returned. In the example screenshot above, a prefabricated component named “pickup_sniper_” is added to the list.

Save the system overview flowchart

Here is an overview of how the save and dialog systems work:

The process of loading is bottom-up. When changing the scene, the process is the same except that the saved game data store is not used. The save system simply keeps the saved data in memory and applies it to the newly loaded scenario. Save the system Perform the following steps when changing the scenario:

  • 1. Tell all the protection components in the current scenario to save their state.
  • 2. Tell all the guard components that they will be uninstalled, so if they update a counter when it is destroyed, they should ignore it this time.
  • 3. Play the “Leave the Current Scene” transformation (for example, fade out or load the Load screen scene) if there is a Scene conversion manager.
  • 4. Load the next scenario asynchronous.
  • 5. If there is a Scene conversion manager, play the Enter New Scene conversion (for example, fade in).
  • 6. Tell all the guard components in the new scenario to update their state from the saved data.

9. Localization

The dialog system supports language localization of the dialog database and provides common text tables. When you change the language from the default setting, the dialog system uses the text in a field that contains a localized version of the specified language. The dialog system supports inter-Illusion I2. If you use I2 localization, you may want to use the dialog system’s I2 localization Support support.

The language code

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

Example language codes are as follows:

Code Code Language Language
es Spanish
ru The Russian Russia
fr-CA French (Canadian)

Localizable dialog database fields

All fields are localized by adding Spaces and language codes to the field names. The only exception is the dialog text field. For conversation text, use the language code alone. Sets the type of the localized field to localized. The following fields are common fields to localize. If no localized field name is defined for the current language, it uses the default field. Common localized dialog input fields For each language LN, the dialog input field is named:

Default Field Localized Field Example
Dialogue Text LN es
Menu Text Menu Text LN Menu Text es
Sequence Sequence LN Sequence es
Response Menu Sequence Response Menu Sequence LN Response Menu Sequence es

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

Default Field Localized Field Example
Name Name LN Name es
Description Description LN Description es
Success Description Success Description LN Success Description es
Failure Description Failure Description LN Failure Description es
Entry # Entry # LN Entry 3 es

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

How do I 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 are automatically added to the asset. Follow the instructions below to add localization to the dialog database. How to Localize the dialog These steps demonstrate how to add Spanish (ES) and Russian (RU) to the dialog.

  • 1. On the Templates TAB, expand the Dialogue Entries dialog record foldout. Folding.

Click + on the same row as the dialog entry title to add the field. In the header, enter the language code. Set Type Type Localization

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

  • On the Conversations TAB, check the dialog entry node.

Add translation to localization field:

How to Localize a Task These steps demonstrate how to add Spanish (ES) and Russian (RU) to a task.

  • 1. Start Quests foldout on the Templates TAB. Folding.

Click + on the same line as the task title to add a field. The Title Title is followed by Spaces and language code. Set the Type Type to Localization

  • On the Tasks TAB, examine a task.

To add your translation to the task:

The dialog editor localizes the export/import collapse

Localization of the import format

10. Script writing

Overview of source code

Namespaces namespace all dialogue system source code is contained in the namespace PixelCrushers. DialogueSystem. Namespace. PixelCrushers code of public library in PixelCrushers namespace. Language.Lua is included in the namespace. Code overview: dialogue system USES the model-view-controller (MVC) architecture: MVC | Description Description – | – | – | dialogue Model Model database, Lua and activity dialogue. View | dialogue UI and cut sequencer. The Controller Controller | mediation between model and view.

Common methods

DialogueManager Class PixelCrushers.DialogueSystem.DialogueManager.Bark:

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

Copy the code

PixelCrushers.DialogueSystem.DialogueManager.BarkString:

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

PixelCrushers.DialogueSystem.DialogueManager.GetLocalizedText:

DialogueManager.SetLanguage("fr");string frenchForCheese = DialogueManager.GetLocalizedText("cheese");
Copy the code

PixelCrushers.DialogueSystem.DialogueManager.PlaySequence:

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

PixelCrushers.DialogueSystem.DialogueManager.SendUpdateTracker:

DialogueManager.SendUpdateTracker(); // Manually refresh quest tracker HUD & quest log window displays.
Copy the code

PixelCrushers.DialogueSystem.DialogueManager.ShowAlert:

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

PixelCrushers.DialogueSystem.DialogueManager.StartConversation:

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

PixelCrushers.DialogueSystem.DialogueManager.StopConversation:

DialogueManager.StopConversation();
Copy the code

DialogueLua Class

PixelCrushers.DialogueSystem.DialogueLua.GetVariable:

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

PixelCrushers.DialogueSystem.DialogueLua.SetVariable:

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

QuestLog Class

PixelCrushers.DialogueSystem.QuestLog.GetQuestState:

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

PixelCrushers.DialogueSystem.QuestLog.SetQuestState:

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

PixelCrushers.DialogueSystem.QuestLog.GetAllQuests:

string[] quests = QuestLog.GetAllQuests()
Copy the code

SaveSystem Class

PixelCrushers.SaveSystem.SaveToSlot:

SaveSystem.SaveToSlot(1);
Copy the code

PixelCrushers.SaveSystem.LoadFromSlot:

SaveSystem.LoadFromSlot(1);
Copy the code

PixelCrushers.SaveSystem.LoadScene:

SaveSystem.LoadScene("Tavern@Entryway"); // Load Tavern scene, move player to position of Entryway GameObject.
Copy the code

Dialog System Attributes

ConversationPopup Attribute ConversationPopup Use the [ConversationPopup] Attribute to convert a string to conversation popup. It takes an optional bool argument 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 the code

Use the [QuestPopup] Attribute in your class definition to convert a string to a Quest popup. It takes an optional bool argument 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 the code

Use the [QuestEntryPopup] Attribute in your class definition to convert an int to a task entry. Note: This property only works if your script has a string variable named ‘quest’, ‘questTitle’, ‘questName’, ‘quest’, ‘questTitle’, or ‘questName’. This is how the task item popup knows which task item to display.

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 the code

11. Import & Export

The dialog 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 the chat mapper
  • Export to comma-separated Values (CSV)
  • Export a voiceover script
  • Export the language Text

Import your own format

. You want to import different formats, please copy the Templates for Scripts for ConverterWindowTemplate. Cs

Export 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

attribute

attribute function
YAxis You can only rotate on the y axis.
Rotate 180 Check if the object is backward facing.

Bark Group Member

Component > Pixel Crushers > Dialogue System > Actor > Bark Group Member Configure the GameObject as a Member of the conversation Group. When one member of a group talks, the other members will hide any activity in the conversation

attribute

attribute function
Group Id A string or Lua expression that specifies a group
Evaluate Id Every Bark Check to reevaluate the member ID.
Forced Hide Delay When hiding an active conversation, wait for the amount of time before actually hiding it.
#### Bark On Idle
Component > Pixel Crushers > Dialogue System > Trigger > Bark On Idle
Dialogue in the idle, at intervals of automatic dialogue.

Cinemachine Priority On Dialogue Event

Component > Pixel Crushers > Dialogue System > Trigger > On Dialogue Event > Cinemachine Priority On Dialogue Event Set the priority of the Cinemachine virtual camera when the dialogue event occurs.

Condition Observer

Component > Pixel Crushers > Dialogue System > Trigger > Condition Observer The Condition Observer checks the Condition at a regular frequency and runs the action if the Condition is true.

Conversation Logger

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

Default Camera Angle

Component > Pixel Crushers > Dialogue System > Actor > Default Camera Angle Sets the Default Camera Angle for the Actor.

Dialogue Actor

Component > Pixel Crushers > Dialogue System > Actor > Dialogue Actor Optional Component that allows you to associate a GameObject with an Actor and configure how it will be displayed in UIs.

Dialogue System Events

Component > Pixel Crushers > Dialogue System > Miscellaneous > Dialogue System Events

Dialogue System Controller

Component > Pixel Crushers > Dialogue System > Misc > Dialogue System Controller This is the main dialog System Component and is described in detail in the dialog Manager section.

Dialogue System Trigger

A dialog System Trigger Component can perform a number of dialog System actions when a triggering event occurs.

Extra Databases

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

Increment On Destroy

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

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 Used for conversations involving GameObjects.

Override Display Settings

Component > Pixel Crushers > Dialogue System > UI > Override > Override Display Settings Overrides the dialog manager’s Display Settings for conversations involving this game object.

Proximity Selector

Component > Pixel Crushers > Dialogue System > Actor > Player > Proximity Selector The Proximity selector gives players an interface to target “usables” and sends them an “OnUse” message by entering their trigger area.

Range Trigger

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

Selector

Component > Pixel Crushers > Dialogue System > Actor > Player > Selector provides an interface for players 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 or approach the selector to use the standard UI selector element.

Sequencer Shortcuts

Component > Pixel Crushers > Dialogue System > Misc > Sequencer Shortcuts Define aliases for the sorter commands.

Standard Bark UI

Component > Pixel Crushers > Dialogue System > UI > Standard UI > Bark > Standard Bark UI displays conversations using the Standard UI System of the conversation System.

Standard Dialogue UI

Component > Pixel Crushers > Dialogue System > UI > Standard UI > Dialogue > Standard Dialogue UI Manages the dialog UI using the dialog System’s Standard UI System.

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 Manage a task log window using the dialog system’s standard UI system.

Standard UI Quest Tracker

Component > Pixel Crushers > Dialogue System > UI > Standard UI > Quest > Standard UI Quest Tracker Manage a task tracking interface using the dialog system’s standard UI system.

Standard UI Subtitle Panel

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

Timeline Trigger

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

Usable

Component > Pixel Crushers > Dialogue System > Actor > Usable specifies that the GameObject is available — that is, the player can target it and send OnUse messages.

Iv. Case demonstration

Case 1: Simple dialogue

1. Create a New Scene (File → New Scene).

Step 2. Drag the prefab Dialogue Manager to enter the scene:

Step 3. Create a dialog database and 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 session.

Step 6 Create two dialog nodes

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

Step 8. Create an empty gameobject and rename it “Player”, create a Cube named NPC and the empty gameobject will be created.

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

Step 10. Click Add Action and select Start Conversation:

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

Step 12. Finally, set the Trigger to On Start. This tells the dialog system that the trigger performs its actions at the start of the scene.

Step 13: Now have your first conversation.

Step 14. Now add the interaction. Click on the NPC to find the Dialogue System Trigger component. Set the Trigger to On Use. The dialog system trigger performs its actions when it receives an OnUse message

Step 15. Add a Usable component for the NPC. This is an interactive component, which means the maximum distance the NPC can be clicked is 30

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

Step 17. Now start the scenario again. Place your mouse over the cube to see the following yellow message:

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

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

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

The source project: download.csdn.net/download/q7…

Case 2: A classic dialogue from Kung Fu

Step 1. Create a dialog database and enter lines

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

Step 3. Specify the dialog database to your new database Player:

Private Hart:

Step 4. Change the Dialogue System dialog skin:

Just find the prefab and drag it into the slot:

Basic Standard UI Selector Elements.prefab

Step 5 give it a try

Source project download:

Github.com/764424567/D…