using UnityEngine;
using System.Collections;
using System.IO;
using System.Text;
public class PersistentDataPathTest : MonoBehaviour {
string path;
void Start () {
//可以把游戏数据持久化到此目录下
//当软件被卸载后,此目录下的数据也会同时被清除掉。
path = Application.persistentDataPath + "/test.txt";
WriteText("test data");
}
void WriteText(string content)
{
StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8);
sw.WriteLine(content);
sw.Flush();
sw.Close();
}
string ReadText()
{
StreamReader sr = new StreamReader(path);
string content = sr.ReadToEnd();
sr.Close();
return content;
}
}
内置SD卡->Android->data
IOS只能把资源下载到temporaryCachePath才能通过审核。