我正在尝试通过命令行进行Asset Bundle Build,我可以做到。使用以下代码:
Object[] selectedAssets = Resources.LoadAll<GameObject>("Prefabs");
Object[] videos = Resources.LoadAll<VideoClip>("Prefabs");
Debug.Log(bundlePath);
Object obje = new Object();
List<Object[]> list = new List<Object[]>();
List<Object[]> listVideo = new List<Object[]>();
for (int i = 0; i < selectedAssets.Length; i++)
{
list.Add(new Object[1]);
list[i][0] = selectedAssets[i];
}
for (int i = 0; i < list.Count; i++)
{
BuildPipeline.BuildAssetBundle(obje, list[i], bundlePath + list[i][0].name, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets , BuildTarget.Android );
}
for (int i = 0; i < videos.Length; i++)
{
listVideo.Add(new Object[1]);
listVideo[i][0] = videos[i];
}
for (int i = 0; i < listVideo.Count; i++)
{
BuildPipeline.BuildAssetBundle(obje, listVideo[i], bundlePath + listVideo[i][0].name, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets , BuildTarget.Android);
}
当我在Unity Editor中尝试时,原始文件为19.255 mb,输出文件为7.623 mb。 如果我在命令行中尝试以下代码:
C:\ Program Files \ Unity \ Editor \ Unity.exe“ -batchmode -createProject” Project Path“-退出
此用于创建项目。
结束:
“ C:\ Program Files \ Unity \ Editor \ Unity.exe” -batchmode -projectPath“项目路径” -executeMethod CreateAssetBundle.ExportBundle -quit
正在执行ExportBundle。
在输出文件变为17.989mb之前。
当我放入BuildAssetBundleOptions.ChunkBasedCompression时,这次变为34.627 mb。
我该如何像打开一样进行压缩并手动使用命令行执行ExportBundle?