Unity很智能只会打包用到的资源,比如sharedassets0.assets中的shader资源,如果场景中有OBJ用到了shader那么就会有shader打进这个包,如果没有就不会打进来。没有打的时候是5k打进来就是90k.
BuildPipeline:
当使用BuildPipeline进行打包时,要注意打包的目标平台,否则无法被加载成功,BuildTarget平台枚举.
文件夹:
StreamingAssets: 为流资源,在这个文件夹里的资源不会被Unity打入到默认的资源包中,
在加载的时候要注意平台相关。
Application.streamingAssetsPath: 获取StreamingAssets的路径对于不同的平台这个不一样,
所以要加载StreamingAssets文件夹中的资源要用这个值。
string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "test.csv");
if (filePath.Contains("://")) // Android平台必须用 www
{
WWW www = new WWW(filePath);
yield return www;
mStrTest = www.text;
}
else
{
// PC 平台 自己写加载方式
mStrTest = System.IO.File.ReadAllText(filePath);
//也可以用www加载,需要用“file://”
filePath = “file://”+filePath;
www file = new www(filePath);
TextAsset txt = file.assetBundle.Load("myBinaryAsText", typeof(TextAsset)) as TextAsset;
}
注意: test.csv名字要大小写匹配
文本文件:
上述加载方式方可。
二进制文件:
文件扩展名要用 .bytes
加载方式上述方式方可。