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

  

相关文章:

  • 2021-06-09
  • 2022-02-02
  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2021-07-15
  • 2021-11-28
  • 2018-10-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案