Unity中有幾個默認目錄 Unity5.x
Resources
項目中默認的資源路徑,會直接打包到游戲包中。即使沒有被使用過的資源,放在該目錄下也會被打包。
Plugins
插件目錄,該目錄在編譯項目時,會優先編譯,方便項目中代碼調用。它與Standard Assets目錄的代碼共同編譯到同一個.sln里。
構建 Android 與 ios 項目時,該目錄下會存放相應的配置文件等資源。
Editor
該目錄下的代碼可調用Unity Editor 的API,存放擴展編輯器的代碼。編譯時不會被打包到游戲包中。
Standard Assets
該目錄下的代碼優先編譯,方便項目中代碼調用。它與Plugins目錄的代碼共同編譯到同一個.sln里。
StreamingsAssets
該目錄下的文件會在打包時打包到項目中,與Resources一樣,沒有被使用過的資源也會被打包。
Resources 與 StreamingAssets 區別
Resources目錄下的文件在打包時會進行壓縮與加密,但StreamingAssets下的文件是直接打包到包中的。
Resources目錄下的材質球、預制件等資源,會在打包時自動尋找引用資源,打包到Resources中。
兩者都是只讀文件。
Unity中路徑獲取API
Application.dataPath
項目根目錄 ../../../Assets
注意在移動設備下無法訪問。
Application.persistentDataPath
該路徑下的文件可讀寫。
Application.streamingAssetsPath
訪問項目目錄中Streaming Assets的路徑。
Application.temporaryCachePath
該路徑下的文件可讀寫。臨時數據,與presistentDataPath的區別只知道是IOS上presistentDataPath的數據會被自動備份到iCloud上。
各平台下路徑API對應具體路徑值(轉)
IOS:
Application.dataPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/xxx.app/Data
Application.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxxxxx/xxx.app/Data/Raw
Application.persistentDataPath : Application/xxxxxxxx-xxxx-xxxx-xxxxxxxxx/Documents
Application.temporaryCachePath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxx/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
來源: http://www.manew.com/forum.php?mod=viewthread&tid=21404&extra=page%3D1%26filter%3Dtypeid%26typeid%3D143