Unity读取StreamingAssets路径下的文件
标签:while pre lan == deb mep str summary sum
///
///读取StreamingAssets中的文件
///
/// StreamingAssets下的文件路径
/// 读取到的字符串
public static string GetTextForStreamingAssets(string path)
{
string localPath = "";
if (Application.platform == RuntimePlatform.Android)
{
localPath = Application.streamingAssetsPath + "/" + path;
}
else
{
localPath = "file:///" + Application.streamingAssetsPath + "/" + path;
}
WWW www = new WWW(localPath);
if (www.error != null)
{
Debug.LogError("error while reading files : " + localPath);
return ""; //读取文件出错
}
while (!www.isDone) { }
Debug.Log("File content : " + www.text);//www下面还有获取字节数组的属性
return www.text;
}
Unity读取StreamingAssets路径下的文件
标签:while pre lan == deb mep str summary sum
原文地址:https://www.cnblogs.com/ezhar/p/12899746.html
评论