首先需要把 SpritePacker设置成可用
菜单Edit->project setting->editor 修改为可用
然后,保证所有图片的导入格式如下
最主要是 packing tag要设置, 相同值的图片会合成一个图集
可以用代码设置
string[] sprites = new string[]{
"Assets/atlas/textures/t1.png",
"Assets/atlas/textures/t2.png",
"Assets/atlas/textures/t3.png",
}; string ab_atlas1 = "ab_atlas1"; for (int i = ; i < sprites.Length; i++)
{
TextureImporter textureImporter1 = AssetImporter.GetAtPath (sprites [i]) as TextureImporter;
textureImporter1.textureType = TextureImporterType.Sprite;
textureImporter1.spritePackingTag = ab_atlas1;
textureImporter1.spriteImportMode = SpriteImportMode.Single;
textureImporter1.SaveAndReimport ();
}
之后按正常打包即可, 另外注意,如果packingtag相同而abname不同,将打到不同的包里。