Okā¦ Iāve now tried to move further from my prototype.
I have made this XML document
<?xml version="1.0" encoding="utf-8" ?>
<dialogue>
<npc1>
<speach1>Speach bubble 1</speach1>
<speach2>Speach bubble 2</speach2>
<speach3>Speach bubble 3</speach3>
</npc1>
</dialogue>
(This code is made to just try and see how I read the first element and then later I will try implant the SPACE funtion to read the next element)
My script looks like this but i totally wrong I know, but I just cant figure out how to make it.
import System.Xml;
import System.IO;
var StringToBubble : String;
function Start()
{
var asset:TextAsset = Resources.Load("xmltest");
if(asset != null)
{
var reader:XmlTextReader = new XmlTextReader(new StringReader(asset.text));
while(reader.Read())
{
if(reader.Name == "npc1")
{
StringToBubble = (reader.Name + reader.ReadChars("speach1"));
}
}
}
}
function Update () {
}
function OnGUI ()
{
GUI.Box (Rect (75, 75, 100, 20), StringToBubble);
}
And I want to start with reading the text in and when the player press like for example SPACE it goes to read
BUT for now it is only done so you can read and nothing else.
But it gives me this error:
Assets/XML-Reader.js(16,81): BCE0017: The best overload for the method āSystem.Xml.XmlTextReader.ReadChars((char), int, int)ā is not compatible with the argument list ā(String)ā.
So I have to type something else in the ReadChars() ?
I found this on MSDN about ReadChars()
public function ReadChars(
buffer : char[],
index : int,
count : int
) : int
But how to use that IF that is the correct way to read and show large amount of text I dont know.
Anyone know what I am doing wrong and can show me how to do it correct? 