- Home /
How to refresh assets during run time of a build ?
Hi,
My primary objective is to detect where are created the files in an android native app which contains a Unity project.
I'm testing today some solution to know if my assets and files are correctly created when running on my device and iIm facing a strange issue.
I know that I can't use the AssetDatabse from the UnityEditor library in a build standalone. But, my problem is to generate a xml from an application, then read it to use it.
I've got this template of code :
void writeTheXml()
{
XmlAttribute attr;
XmlDocument xmlDoc = new XmlDocument();
XmlNode rootNode = xmlDoc.CreateElement("Moody");
attr = xmlDoc.CreateAttribute("name");
attr.Value = "TMP";
rootNode.Attributes.Append(attr);
xmlDoc.AppendChild(rootNode);
XmlNode hair = xmlDoc.CreateElement("Hair");
attr = xmlDoc.CreateAttribute("id");
attr.Value = "1";
hair.Attributes.Append(attr);
rootNode.AppendChild(hair);
XmlNode eyes = xmlDoc.CreateElement("Eyes");
attr = xmlDoc.CreateAttribute("id");
attr.Value = "1";
eyes.Attributes.Append(attr);
rootNode.AppendChild(eyes);
string path = Application.dataPath + "/Resources/XML/TMP.xml";
try
{
xmlDoc.Save(path);
Debug.Log("Xml saved --> " + path);
GameObject.FindGameObjectWithTag("Name").GetComponent<Text>().text = "XML saved : " + path;
TextAsset binary = Resources.Load<TextAsset>("XML/TMP");
}
catch (Exception e)
{
GameObject.FindGameObjectWithTag("Name").GetComponent<Text>().text = e.Message;
}
}
During the execution I got the following line : XML saved : D:/Workspace Unity/XmlReader/Assets/Resources/XML/TMP.xml
But the XML take some times to be displayed :
So I can't use my XML to do other things but the files has been created. How can I refresh my assets list without using the AssetDatabase (because you can't build with it) ?
Second question, if I may, where does the files created when running into a native android app are located ?
Thx !