What are you wanting to do using UI Toolkit exactly? Wouldn’t bone-based animations of this kind be a bit overkill for UI?
The sprite renderer which is capable of accessing bone data etc. is not compatible with UI toolkit unfortunately and think not for “old” Ugui either (but that can be interwebbed with normal rendering if really needed).
For a full on funky, creative UI you might need to use normal sprite renderers. That gives you all liberty (like this) but at cost of convenience when it comes to automatically adapting to screen ratio.
I’m working on some card UI with UI toolkit, and animating the transitions between cards with the ones that uitk provides. Inside the card I want some spine-like animation of some 2d characters. I recently started looking to see how to integrate spine with this, and ended up here.
I was comparing 2D Animation package with Spine a bit, and there was one neat feature that is missing. I wonder if it’s possible to implement:
In Spine, you can animate vertexes directly without bones. It’s actually pretty useful if you need to deform body a bit during, for example, run cycle. It’s possible to do so with extra bones, but it may require an insane amount of bones on some cases.
Stuff like blend shapes may be useful as well, but it can be implemented with a custom script if vertex animations are there.
@leyreley have a look at our latest UI Toolkit sample (link). This sample makes use of 2D Animation and UI toolkit, which might give you some inspiration.
@GamerXP thank you for the feedback. How do you see yourself animating the vertices? and how would it look like within the Animation Window? I’ll add this to our backlog.
You select an object with SkinMesh and it shows you sprite’s verticles and edges. You can then select any and do movement, rotation and scale with them.
Well, thing is… I somehow doubt it’s possible to do with current Unity’s animation system. Because it can’t animate array’s values. Maybe some internal magic can do something about it.
My friend made a working prototype of something like that where it generated an empty object for selected vertices to use as handles in animation. Not sure if he is still working on it.
(My hacky solution was just to add a bone to each vertex I wanted to animate, which was obviously not ideal but it works.)
I think that being able to save blendshapes to the sprite mesh would be a nice alternative.
This is a known bug with Sprite Resolver/Sprite Library’s Category & Label hashing values. This has been fixed in Unity 2022.1 and onwards, if the Animation Clip makes use of the new Sprite Hash-value to key the Category/Label in the animation. If your animation clip does not utilise Sprite Hash, you can use our upgrading tool (also in Unity 2022.1 and onwards) to upgrade the values in your clips.
This fix worked for my problem! Originally I only cipied the bones and binding pose, but after a mandatory Unity Upgrade, it broke for some reason and the Sprite Skin was always showing me the error “bone weights are invalid”. I tried a similar block of code that you posted in the “InjectBoneWeights” function, which also copied the vertex attributes, but it didn’t work all the time for some reason. With your version it seems to completely fix it for all my sprites, thank you!