说一说Unty3d中的资源存放目录和获取方法

    首先,讲一讲unity3d中的一些目录,不是Assets下的Resources等特殊文件夹,而是系统读写目录:

    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/streamingAssetsPath 

    Application.persistentDataPath :  /xxx/xxx/xxx

    Application.temporaryCachePath :  /xx/xx/xx


    dataPath:程序安装目录,或者说程序根目录,只读

    streamingAssetsPath:未被压缩的资源存储目录,只读

    persistentDataPath:持久化数据目录,沙盒目录,通常作为存盘目录,读写

    temporaryCachePath:临时缓存目录,会被系统回收,可存放下载的临时文件,读写


    在Windows下,Resources下面的资源不压缩,所以可以使用datapath/Resouces获取,而在IOS和Android下面,Resources目录资源被压缩,此方法无法获取Resouces目录下的资源,必须使用Resources.Load或者别的系统方法才能获取Resources目录下的资源。streamingAssetsPath下的资源可WWW类获取。所以,通常情况下真机运行时dataPath不会使用到。

    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章