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