1,streamingAssetsPath 可读不可写
1.在windows pc上可以使用www直接读取streamingAssetsPath路径下的文件。也可以使用File直接读取。
2.android上www可以读取streamingAssetsPath,但是使用file是读取不到的
3.mac上使用www读取不到streamingAssetsPath,可以使用file读取
4.ios上使用www读取不到streamingAssetsPath,可以使用file读取
2,Application.persistentDataPath
1.Application.persistentDataPath 是可读可写路径,一般热更资源放在这边
2. IOS中读取目录下的ab包
AssetBundleCreateRequest createRequest =AssetBundle.LoadFromMemoryAsync(File.ReadAllBytes(Application.persistentDataPath + "/AssetBundles/IOS/翻译静态数>据")); yield return createRequest; AssetBundle bundle = createRequest.assetBundle;
在IOS中读取文本
Debug.Log("文件链接:" + path + "/" + name); // UnityWebRequest w = UnityWebRequest.Get(st+path + "/" + name); // new Task(ShowDownProgress(w)); //w.SendWebRequest(); FileStream fs = new FileStream( path + "/" + name, FileMode.Open, FileAccess.Read, FileShare.Read);//找到指定路径的文件,打开,读取;using自动释放资源并且关闭 StreamReader sr = new StreamReader(fs, Encoding.Default);