Conversation Entry

ConversationEntry

Below is the code for a simple class that has elements for each ConversationEntry: Since we use the Class-Level Attribute: [System.Serializable], then we'll be able to display and populate each ConversationEntry in our list in the inspector panel.

Each ConversationEntry corresponds to one instance of conversation dialogue. The class defines the data elements that are associated with a single chunk of conversation: speakerName, speakerImage, dialogTxt. Notice that the class does not contain any methods. Notice the variable-level [TextArea] attribute, this will create a larger input field in the inspector when creating each piece of conversation dialogue.

Create an instance of this C# script in your Unity project, paste the code below into the script within Visual Studio.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

[System.Serializable]
public class ConversationEntry
{
    public string speakerName;

    [TextArea]
    public string dialogTxt;

    public Sprite speakerImg;
}

Last updated