I’ve been trying a while now to get an XML document full of DialogItems and Objectives to be deserialized and for it to populate text objects at runtime.
Specifically dialog lines to change in time with audio files, and then objectives per level.
I’ve tried following several tutorials but can never quite get it to work. Even this one, which I thought was closer to what I had in mind.
Can anyone point me in the right direction? I also have a Dialog class and as I understand it I’d need a script to actually deserialize it, but I also expect I’ll need a separate script to access the deserialized data and populate said text objects.
Thanks in advance
<?xml version="1.0" encoding="utf-8"?>
<All>
<DialogList>
<DialogItem>
<LL-1>
<num>1</num>
<level>Lobby</level>
<content>
This is a line of dialog 1.
</content>
</LL-1>
</DialogItem>
<DialogItem>
<LL-2>
<num>2</num>
<level>Lobby</level>
<content>
This is a line of dialog 2.
</content>
</LL-2>
</DialogItem>
<DialogItem>
<LL-1-alt>
<num>0</num>
<level>Lobby</level>
<content>
This is an alternate line of dialog 1.
</content>
</LL-1-alt>
</DialogItem>
<DialogItem>
<L1-1>
<num>3</num>
<level>1</level>
<content>
This is a line of dialog 3.
</content>
</L1-1>
</DialogItem>
<DialogItem>
<L1-2>
<num>4</num>
<level>1</level>
<content>
This is a line of dialog 4.
</content>
</L1-2>
</DialogItem>
<DialogItem>
<L1-3>
<num>5</num>
<level>1</level>
<content>
This is a line of dialog 5.
</content>
</L1-3>
</DialogItem>
<DialogItem>
<L1-4>
<num>6</num>
<level>1</level>
<content>
This is a line of dialog 6.
</content>
</L1-4>
</DialogItem>
</DialogList>
<ObjectivesList>
<Objective>
<O1-1>
This is an objective for level 1.
</O1-1>
</Objective>
</ObjectivesList>
</All>
using System.Xml;
using System.Xml.Serialization;
using System.IO;
[XmlRoot("All")]
public class Dialog
{
[XmlAttribute("num")]
public int num { get; set; }
[XmlAttribute("level")]
public string level { get; set; }
public string content { get; set; }
}