Unity资源加载机制www的坑

Unity目前已使用UnityWebRequest代替www加载,如果机制允许,直接替换掉你项目中的加载机制,否则继续往下看

在不同的平台上运行时,www加载的路径不同,协议类型也有差别!

在unity编辑器模式或者苹果(ios)下加载资源:

string path=@"file:///"+ Application.streamingAssetsPath + "/" +"文件全名";//一定要加上@"file:///"
WWW www = new WWW(path);

在安卓平台上加载资源:

Application.streamingAssetsPath在安卓平台默认为有 "jar:file:///" 前缀,使用www加载可以直接使用
string path= Application.streamingAssetsPath + "/" +"文件全名"; 
WWW www = new WWW(path);

 

原文地址:https://www.cnblogs.com/RainPaint/p/11097855.html