Changeing Sprite Problem in SpriteResolver and SpriteSkin

My animations not working when I change sprites from Sprite Library Asset with a script.
But it work correctly when I change it in Unity Editor in play mode.
I use this code:

mySpriteResolver.SetCategoryAndLabel(clothCategory, clothes[clothIndex]);
mySpriteResolver.ResolveSpriteToSpriteRenderer();

When i change sprite with code, i get this warning in the editor in SpriteSkin component:
“the number of sprite’s bind poses and the number of transforms should match”
and when i change it in SpriteResolver component in editor, animations play correctly and the warning is gone.

I don’t have problem with all of the sprites.
Some of my clothes used only 5 bones; and some of them use more than those 5 bones.
When i select sprite with more than 5 bone, i can see all of the bones in the scene view but when i change it with script, i see main 5 bones that common in all sprites and it doesn’t show extra bones.

6909665--809612--Unity_LK4y3lmMyV.png

I’m having the same problem. Though, I don’t have any errors at all. I can swap out sprites just fine using the editor but have no luck with using SetCategoryAndLabel() in code.

I found a fix. Though I’m still a bit confused.

I had a button that would trigger a function on a characterController to swap out sprites. That button worked and it would invoke the correct function on the character. However, the sprites wouldn’t change (Though they would be changed when I re-ran the game ¯_(ツ)_/¯). I think the problem is that I was spawning in this character at runtime and there was some disconnect.

I changed the button to trigger an event via an eventManager rather than invoking the function on the characterController and it worked!