我已经完成了一个导入和导出脚本,该脚本导入/导出一个包含所有当前生成的对象及其XYZ坐标的文件.然而,仍然存在一个问题.我现在在导出时所做的是将文件自动保存在"Application.persistentDataPath"中,但我希望弹出一个窗口,请求您将文件保存在PC上的什么位置,以及导入文件的位置.
以下是导入和导出的代码:
public void WriteString(string message)
{
// string path = Application.persistentDataPath + "/"+display.text+".txt";
string path = Application.persistentDataPath + "/txt.txt";
//Write some text to the test.txt file
StreamWriter writer = new StreamWriter(path, true);
writer.WriteLine(message);
writer.Close();
StreamReader reader = new StreamReader(path);
//Print the text from the file
Debug.Log(reader.ReadToEnd());
reader.Close();
}
public void ReadString()
{
// string path = Application.persistentDataPath + "/"+display.text+".txt";
string path = Application.persistentDataPath + "/txt.txt";
StreamReader reader = new StreamReader(path);
string line = "";
...
}