在Unity的StreamingAssets下放了一个shootRecord.txt文件
在安卓平台下变成了jar:file:///data/app/com.enjoy2.EnjoyReplay2-vjTe-kN-zK-elcFb7aPwJw==/base.apk!/assets/shootRecord.txt
由于安卓平台jar变成了压缩包,所以无法直接使用File.ReadAllLines来读取,而要使用www。
string dataFile = Path.Combine(Application.streamingAssetsPath, "shootRecord.txt");
if (Application.platform == RuntimePlatform.Android)
{
WWW reader = new WWW(dataFile);
while (!reader.isDone) { }
string textString = reader.text;
Debug.Log(textString.Length);
List striparr = textString.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList();
List lines = striparr.Where(s => !string.IsNullOrEmpty(s)).ToList();
}
else
{
string textString = File.ReadAllText(dataFile);
Debug.Log(textString.Length);
List striparr = textString.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList();
List lines = striparr.Where(s => !string.IsNullOrEmpty(s)).ToList();
}