Unity Android路径及注意事项

Application.temporaryCachePath==/storage/emulated/0/Android/data/com.***.***/cache

Application.persistentDataPath==/storage/emulated/0/Android/data/com.***.***/files

 

或许你碰到过,在电脑读取该目录下的文件一点问题也没有,突然发不到Android怎么也读取不到。是吧即便路径改成Android上的路径也读取不到 "jar:file://" + Application.dataPath + "!/assets";

嗯嗯嗯,Android上就是这么特殊,其实不是文件路径不对,而是在Android上读取文件的方式不对哎
他需要以WWW的方式去读。好坑啊

path=Application.streamingAssetsPath+“文件名。后缀”

string str;
IEnumerator ReadFile(string path)
    {
        WWW www = new WWW(path);
        yield return www;

        if (string.IsNullOrEmpty(www.error))
        {
            str= www.text;
        }
    }

posted on 2017-04-16 17:28  Jason_c  阅读(4494)  评论(0编辑  收藏  举报