I am working on an RPG dialogue system where each dialogue line consists of the actual dialogue being spoken, the name of the speaker, and a facial expression for the speaker, if applicable. I have done this by creating the following Dialogue class and creating a public Dialogue list within a DialogueHolder class, allowing me to edit dialogue within the editor.
[System.Serializable]
public class Dialogue {
public string name;
public Sprite emote;
[TextArea] public string line;
public Dialogue(string n, string l, Sprite e)
{
name = n;
emote = e;
line = l;
}
}
However, on a previous project, I used a different approach for storing dialogue. I used a struct, named DialogueLine, instead of a class, and loaded each line from a text file, using semicolons to separate information.
public void LoadDialogue(TextAsset textToLoad)
{
int i = 0;
string[] textLines;
// Separate the text into lines
textLines = (textToLoad.text.Split('
'));
// Add each line to the list
do
{
string[] lineData = textLines*.Split(';');*
DialogueLine lineEntry = new DialogueLine(lineData[0], lineData[1], lineData[2][0]);
lines.Add(lineEntry);
i++;
} while(i < textLines.Length);
}
What I want to know is which of these two methods is better: storing dialogue within the editor or using external text files and reading them in. I can already see some pros and cons of each approach in regards to ease of use, but is there something I’m not factoring in (i.e. performance) that should convince me to chose one over the other?