Hey,
Sorry for necroing this thread, but it seemed more appropriate than to start a new one.
I am currently attempting to override a material at runtime ("atlas material"?). We've got it setup so that theres just one material per character but the process of overriding that material still has me scratching me head.
We're using material property blocks, and thats working fine, however, at times the characters in question has got to disable/enable certain shader effects for performance reasons, which is why material property blocks cant be the end all solution, at least in this case.
Initially the shaders were #pragma multi_compile or feature shaders to deal with that, but they don't exactly go hand in hand with Spine, which is shame - so the only option left is to split the shader features into seperate shaders & materials and swapping it out at runtime depending on the situation.
I've seen methods such as GetComponent<SkeletonAnimation>().CustomMaterialOverride.Add(originalMaterial, newMaterial); mentioned, as well as skeletonAnimation.CustomSlotMaterials[slotObject] = material; but it's really unclear to me on how to override the atlas material in an efficient manner.
The Skeleton Custom Materials is nice but seems a bit "hacky" since it loops through all of the slots, if I understand it correctly? It would really like for some references and examples regarding how to best achieve it in C# in an efficient manner especially since it seems to be a topic which pops up every now and then.
Finally,(without having to delve too deep into the structure of spine) arent we looking at a substantial overhead when overriding materials with the way that spine is structured? Overhead is of a concern since we're working a mobile title, and that material swapping will occur quite often).
Hopefully I've just missed or overlooked something.
Thanks