- Home /
Question by
Yooooooooz · Mar 18, 2016 at 12:22 PM ·
textunity5xml
How to keep the XML text in the UGUI.Text that has been load?
I use UGUI to show text of my xml but The new text appears, the old text is gone I want all my text on the screen what should I do
here`s code
using UnityEngine; using System.Collections; using System.IO; using System.Xml; using UnityEngine.UI; public class new_XmlLoda : MonoBehaviour { public int index = 0; public string dialogue;
public float dia_interval = 1.0f;
// Use this for initialization void Start () {
}
// Update is called once per frame
void Update () {
XmlDocument xml = new XmlDocument();
xml.Load("E:/unity5project/project_AVG/project_avg/Assets/Resources/duihua_1.xml");
XmlNode xnl = xml.SelectSingleNode("dialogue");
XmlNodeList xl = xnl.ChildNodes;
dia_interval -= Time.deltaTime;
if (dia_interval < 0)
{
dia_interval = 1.0f;
index += 1;
}
if (index < xl.Count)
{
//how to keep this on the screen?
dialogue = xl.Item(index).InnerText;
}
}
}
Comment