Hi, I have a pipeline that creates many atlases prefabs using UIAtlasMaker API, through an editor script. This tool will create a material, a texture, and a prefab. After the generation, to test one of the newly created atlas Prefab, I dragged it into the Atlas Maker for viewing, the material, texture, and the sprite list looks good. (See attached PipelineTest.png)
I then take these atlases & move them to the appropriate game projects. These atlases are then imported into this Unity project. Again, I try testing out an atlas prefab by opening it in the Atlas Maker, the links to the material, & materials' link to the texutre, and the sprite list textures are disconnected (or empty). (See attached NewProject_onImport.png). Even if I try to reconnect the material & texture, the sprite list is still showing up as 0x0. (See attached NewProject_reconnect.png).
Any ideas here?
Thank you
Unity 5.1.3f1
NGUI 3.9.0
My pipeline tool script to create the atlas prefab is summarized below:
1. Load all needed png images as Texture2D into an array, allImageTex
2. Create a new Texture2D for the atlas material, atlasTex, & save to png:
File.WriteAllBytes (texturePath, atlasTex.EncodeToPNG ());
3. Create a new Material:
var material
= new Material
(Shader
.Find ("Unlit/Transparent Colored"));
4. Call PackTextures:
Rect [] coordinates = atlasTex.PackTextures (allImageTex.ToArray(), ATLAS_PADDING, TEXTURE_MAX_SIZE);
5. Set the material to the atlas texture:
material.SetTexture ("_MainTex", atlasTex);
6. Save out the material texture:
AssetDatabase.CreateAsset (material, newFolderDir + ".mat");
7. Loop through the Rect coordinates to create new UIAtlasMaker.SpriteEntry
UIAtlasMaker
.SpriteEntry se
= new UIAtlasMaker
.SpriteEntry();se.x = Mathf.RoundToInt(coordinate.x * width);
se.y = Mathf.RoundToInt(coordinate.y * height);
se.width = Mathf.RoundToInt(coordinate.width * width);
se.height = Mathf.RoundToInt(coordinate.height * height);
se.name = allImageTex[i].name;
se.SetTexture(texPixels, se.width, se.height);
8. Update the atlas with the list of SpriteEntry per sprite texture added:
UIAtlasMaker.UpdateAtlas(atlas, listSpriteEntry);
atlas.MarkAsChanged();