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;
        }
    }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM