- Home /
This question was
closed May 27, 2013 at 03:50 AM by
sona.viswam for the following reason:
The question is answered, right answer was accepted
Question by
sona.viswam · May 14, 2013 at 06:41 AM ·
arraytext
error in xml script
for xml i used script
using UnityEngine; using System.Collections; using System.Xml;
public class XMLEditor : MonoBehaviour {
void Awake()
{
//Load
TextAsset textXML = (TextAsset)Resources.Load("myxml.xml", typeof(TextAsset));
XmlDocument xml = new XmlDocument();
xml.LoadXml(textXML.text);
}
}
gets error
NullReferenceException: Object reference not set to an instance of an object
XMLEditor.Awake () (at Assets/XMLEditor.cs:13)
how to escape from this error
Comment
Best Answer
Answer by whydoidoit · May 14, 2013 at 06:45 AM
The file must be in the root of a Resources folder somewhere within the project
i removed as you said. TextAsset textX$$anonymous$$L = (TextAsset)Resources.Load("myxml", typeof(TextAsset));
still i have same error
its in asset folder itself
xml.LoadXml(textX$$anonymous$$L.text);
in this it shows error
Resources can only be loaded from a Resources folder (or a sub folder of a Resources folder).