IOS:
Application.dataPath :                      Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data
Application.streamingAssetsPath :   Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw
Application.persistentDataPath :      Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents
Application.temporaryCachePath :   Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/Caches

Android:
Application.dataPath :                         /data/app/xxx.xxx.xxx.apk
Application.streamingAssetsPath :      jar:file:///data/app/xxx.xxx.xxx.apk/!/assets
Application.persistentDataPath :         /data/data/xxx.xxx.xxx/files
Application.temporaryCachePath :      /data/data/xxx.xxx.xxx/cache


Windows:
Application.dataPath :                         /Assets
Application.streamingAssetsPath :      /Assets/StreamingAssets
Application.persistentDataPath :         C:/Users/xxxx/AppData/LocalLow/CompanyName/ProductName
Application.temporaryCachePath :      C:/Users/xxxx/AppData/Local/Temp/CompanyName/ProductName


Mac:
Application.dataPath :                         /Assets
Application.streamingAssetsPath :      /Assets/StreamingAssets
Application.persistentDataPath :         /Users/xxxx/Library/Caches/CompanyName/Product Name
Application.temporaryCachePath :     /var/folders/57/6b4_9w8113x2fsmzx_yhrhvh0000gn/T/CompanyName/Product Name


Windows Web Player:
Application.dataPath :             file:///D:/MyGame/WebPlayer (即导包后保存的文件夹,html文件所在文件夹)
Application.streamingAssetsPath :
Application.persistentDataPath :
Application.temporaryCachePath :

------------------------------------------------------------------------------------------------------------------------------

1.Resources文件夹 

Resources文件夹是一个只读的文件夹,通过Resources.Load()来读取对象。因为这个文件夹下的所有资源都可以运行时来加载,所以Resources文件夹下的所有东西都会被无条件的打到发布包中。建议这个文件夹下只放Prefab或者一些Object对象,因为Prefab会自动过滤掉对象上不需要的资源。举个例子我把模型文件还有贴图文件都放在了Resources文件夹下,但是我有两张贴图是没有在模型上用的,那么此时这两张没用的贴图也会被打包到发布包中。假如这里我用Prefab,那么Prefab会自动过滤到这两张不被用的贴图,这样发布包就会小一些了。 

2.StreamingAssets

StreamingAssets文件夹也是一个只读的文件夹,但是它和Resources有点区别,Resources文件夹下的资源会进行一次压缩,而且也会加密,不使用点特殊办法是拿不到原始资源的。但是StreamingAssets文件夹就不一样了,它下面的所有资源不会被加密,然后是原封不动的打包到发布包中,这样很容易就拿到里面的文件。所以StreamingAssets适合放一些二进制文件,而Resources更适合放一些GameObject和Object文件。 StreamingAssets 只能用过www类来读取!!

------------------------------------------------------------------------------------------------------------------------------

StreamingAssets,在不同的平台上面 (Windows, Ios ,Android),该目录最终发布的位置不同,所以读取的方法也不同。



unity删除注册表 unity 注册表_贴图


WWW是异步加载所以执行加载命令式不能直接执行读取解析操作,

要等待

WWW www = new WWW(filePath);
 
 
 
yield return www; // while (!www.isDone) {}
result = www.text;




 

StreamingAssets下的文件

都包含在压缩的.jar文件中(这基本上与标准的zip压缩文件的格式相同)。这意味着,如果你不使用Unity中的WWW类去检索文件,那么你需要使用额外的软件去查看.jar的存档并获取该文件。



------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


安卓上跟其他平台不一样,安装后,这些文件实际上是在一个Jar压缩包里,所以不能直接用读取文件的函数去读,而要用WWW方式。具体做法如下: 
1.把你要读取的文件放在Unity项目的Assets/StreamingAssets文件夹下面,没有这个文件夹的话自己建一个。 
2.读取的代码(假设名为"文件.txt") 


1. byte[] InBytes;                                                                                                        //用来存储读入的数据   
2. if (Application.platform == RuntimePlatform.Android)                                            //判断当前程序是否运行在安卓下   
3. {   
4. string FileName = "jar:file://" + Application.dataPath + "!/assets/" + "文件.txt";   
5. new WWW(FileName);                                                            //WWW会自动开始读取文件   
6. while(!www.isDone){}                                                                       //WWW是异步读取,所以要用循环来等待   
7. //存到字节数组里   
8.   
9. }   
10. else   
11. {   
12. //其他平台的读取代码   
13. }