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