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
加載方式上述方式方可。