Hi,
I’m trying to get strings from .xml file (located in Resources folder) and use them as text for TextMesh. It’s done as follows:
File reading:
Dictionary<string, string> strings = new Dictionary<string, string> ();
XmlDocument xmlDoc = new XmlDocument();
TextAsset textFile = Resources.Load<TextAsset> ("fileName");
xmlDoc.LoadXml(textFile.text);
XmlNodeList stringsList = xmlDoc.GetElementsByTagName("string");
foreach (XmlNode stringItem in stringsList) {
strings.Add (stringItem.Attributes["name"].Value, stringItem.InnerText);
}
Using string:
TextMesh someLabel = some.GetComponent<TextMesh>();
someLabel.text = strings[someName];
Strings are reading and showing correct, except the case when it contains "
" symbols. "
" is working as a regular text part and doesn’t replaced by line break.
If I pass string directly
someLabel.text = "first
second";
it works correct.
Thanks!