unity Android在streamingAssets路徑下文件無法讀取的的解決方法


unity Android在streamingAssets路徑下文件,有時候plugin下的.jar或者.so無法直接讀取;

解決方法之一,拷貝至其他路徑:

#if  UNITY_ANDROID
        string  s = Application.streamingAssetsPath + "/s/ss.txt";
         string filePath = Application.persistentDataPath + "/s";
        if (!File.Exists(filePath+ "/ss.txt"))
        {
            using (WWW www = new WWW(s))
            {
                yield return www;
                if (!string.IsNullOrEmpty(www.error))
                {
                    Debug.Log(www.error);
                }
                else
                {
                    if (!Directory.Exists(filePath))
                    {
                        //創建文件夾
                        Directory.CreateDirectory(filePath);
                    }
                    File.WriteAllBytes(filePath+ "/ss.txt", www.bytes);
                }
            }
        }

#endif

  


免責聲明!

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



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