Unity資源加載方式總結


1、Resource.load(string path)
優點:同步,使用方便
缺點:只能加載Resource目錄下的資源

2、WWW
優點:靈活,可以加載Application.streamingAssetsPath、Application.persistentDataPath目錄下的資源,以及從網絡上下載資源
缺點:異步,如果業務需要按需加載資源,容易打散邏輯

3、AssetBundle.CreateFromFile(string path)
優點:同步,可以加載Application.persistentDataPath目錄下的AssetBundle
缺點:AssetBundle不能壓縮,在Android下不能加載Application.streamingAssetsPath下的AssetBundle

4、AssetBundle.CreateFromMemoryImmediate(byte[] binary)
優點:同步,可以加載Application.persistentDataPath目錄下壓縮過的AssetBundle
缺點:在Android下不能加載Application.streamingAssetsPath下的AssetBundle


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM