因此,也有了一般的思路:在streamingAssetPath中读取二进制文件后移到persistentPath下进行后续读写,并且玩家的存档等文件也存放在persistentPath下。 二.读取资源 说3种方法,如下: 1.Application.streamingAssetsPath和Application.persistentPath2.Resources3.AssetBundle 第一种: 有个很重要的东西要说,就是streamingAssetPat...
Persistent Data Path:Application.persistentDataPath,这是一个可读写的路径,适合存储用户生成的内容。 Streaming Assets:Application.streamingAssetsPath,该路径用于存储那些需要随应用一起打包的文件,但不适合频繁修改。 Temporary Cache:Application.temporaryCachePath,用于临时文件存储,通常在应用关闭后会被清除。 代码实现 下...
//将数据文件复制到Persistent路径下 public static void SetFileToPersistent() { FileInfo info = new FileInfo(Application.persistentDataPath + "/PlayerInfo.xml"); if (!info.Exists) { try { TextAsset ts = Resources.Load("VariousInfos/PlayerInfo") as TextAsset; string content = ts.text; using ...
usingUnityEngine;usingSystem.IO;publicclassPersistentDataPathExample:MonoBehaviour{privatestringfileName="example.txt";voidStart(){stringpath=Path.Combine(Application.persistentDataPath,fileName);WriteToFile(path,"Hello, Persistent Data Path!");ReadFromFile(path);}voidWriteToFile(stringpath,stringcontent){File.Wr...
Application.persistentDataPath public static string persistentDataPath ; 描述 (Read Only) Contains the path to a persistent data directory.该值是目录路径;此目录中可以存储每次运行要保留的数据。在 iOS 和 Android 上发布时,persistentDataPath 指向设备上的公共目录。应用程序更新不会擦除此位置中的文件。用户...
//将数据文件复制到Persistent路径下publicstaticvoidSetFileToPersistent(){FileInfo info=newFileInfo(Application.persistentDataPath+"/PlayerInfo.xml");if(!info.Exists){try{TextAsset ts=Resources.Load("VariousInfos/PlayerInfo")asTextAsset;string content=ts.text;using(FileStream fs=newFileStream(Application.pe...
其他平台获取的方式为Application.streamingAssetsPath 使用 WWW 异步加载 加载StreamingAssets文件夹里面的AssetBundle 要注意 Android获得去方式为Application.streamingAssetsPath 其他平台获取的方式为"file://" + Application.streamingAssetsPath PersistentData文件夹获取的方式都为Application.persistentDataPath...
```csharp private void TestCopy() { string from = Application.streamingAssetsPath + "/Test/test.txt"; string to = Application.persistentData
经查发现Application.temporaryCachePath和Application.persistentDataPath返回空字符串。便花时间认真研究了一下...
yield return StartCoroutine(CopyAssetFileToPersistentPath("OrderMenuData.xml", strDestDir)); } IEnumerator CopyAssetFileToPersistentPath(string assetFile,string destFile) { string src = (new System.Uri(Path.Combine(Application.streamingAssetsPath ,assetFile))).AbsoluteUri; ...