- Editado
[Unity] Multi page atlas not correctly set?
I export from Spine with the constrain 1024x1024, Spine produce skeleton.png and skeleton2.png because it does not fit in 1 atlas. (I choose to sacrifice draw calls for extra space saved from one big 2048x2048)
Then in Unity I proceed to create necessary files for the character. I created 2 materials for skeleton.png and skeleton2.png and assign it via the Spine Atlas file. But when I attach the Skeleton Data to my Game Object, first in the Mesh Renderer it display only one material which is understandable. But then when I select a skin that does use images in both material, the Mesh Renderer does got updated to 2 materials, but, those two are the same, which is the first material.. And no, I can't forcefully change the second one to my "CharMaterialSecond" because the editor script seems to be automatic and prevent me from setting it. And so the output produces erroneous result.
In the .atlas file it does contain both data of skeleton.png and skeleton2.png as seen in the screen shot. And I'm sure I have set the skeleton.png in my CharMaterial and set skeleton2.png in CharMaterialSecond.
I just upgraded to Unity 4.5 by the way. So I wondered if this was caused by the latest update or not?
Update : Suddenly (not sure at what point, probably close and open Unity again?) The output finally correctly show nice result but, the materials now ranges from 1 to 3 or even 5 depending on the animation! And the draw calls are equal to number of materials shown. In this screenshot, draw call is 5. My draw call count will even varying mid-animation because of this.
The number of materials change if the order of the parts/images change, or of some of them are hidden or shown or swapped.
Extra material entries are made based on the number of times the draw order changes its source of parts. The worst case is when it draws from material 1, then from material 2, then 1, then 2, then 1 until it's done.
It's not a bug, It's just how it works. The increased number of draw calls is the cost of pulling from multiple atlases.
If it's worth anything:
Unity's old documentation mentions that "if it’s more than several thousand (for PCs) or several hundred (for mobile), then you might want to optimize the object count."
If you're not anywhere near those numbers, you shouldn't worry about it at all. If something's slowing you down in that case, it's not the draw call count.
I observe that restarting Unity will often solve the erroneous output problem, and the material problem is nicely explained by you.
I think I'm all clear now. Thank you!