I am building a unity app and I want to do the following. 1. a language menu, when clicked I send a number to other parts to do the rest 2. I need an XML file, to store every building info in it, so I can build a light weight app to be run on android. my app is about old building info in multiple language. I have found some code and it is not helping. I am a little bit exhausted, but I really need your help if you please. thanks in advance.
using UnityEngine;
using System.Collections;
using System.Xml;
public class ChatNPC : MonoBehaviour {
//building data
private string buildingName;
private string buildingType;
private string TypeName;
//info data
public int maxdata;
public int showdata;
private string [] data;
private XmlReader reader;
void OnGUI (){
if (showdata < maxdata) {
GUI.Label (Rect (0,0,200,20), TypeName);
GUI.Label (Rect (0,20,200,10) , data [showdata]);
if (GUI.Button(Rect (0,120,200,20) , "Next"))
{
showdata++;
if (showdata>maxdata)
showdata = 0;
}
}
}
// Use this for initialization
void Start () {
TypeName = buildingType + ":" + buildingName;
maxdata = 0;
showdata = 0;
buildingName = "Unset";
buildingType = "Unset";
data = null;
reader = XmlReader.Create ("testXml.xml");
while (reader.Read()) {
if (reader.IsStartElement("buildings"))
{
buildingName = reader.GetAttribute("name");
buildingType = reader.GetAttribute("buildingsType");
maxdata = reader.GetAttribute("entries");
data = new string[maxdata];
for (int showdata = 0; showdata < maxdata; showdata++)
{
reader.Read();
if (reader.IsStartElement("text"))
{
data[showdata] = reader.ReadString();
}
}
showdata=0;
}
}
}
// Update is called once per frame
void Update () {
}
}
No comments:
Post a Comment