Affinity

I've made several skeletons for my game's HUD / UI.
Unlike how I've been using Spine till now SkeletonGraphic seemed somewhat more fitting than SkeletonAnimation, but that was just a wild guess.

What I'm really asking is:
Is SkeletonGraphic for the use of Canvas / UI element?
If so, I'm currently not able to play animated clips of the skeleton with SkeletonGraphic, but able to do so with SkeletonAnimation.

If you've some experience with above, or experience with making UI stuff with Spine any input would be helpful.
Thanks.
Affinity
記事: 28

Pharan

Yes, SkeletonGraphic is for use with Unity UI. It derives from UnityEngine.UI.MaskableGraphic so it works with Unity's UI.

What do you mean by "not able to play animated clips of the skeleton"?
Are you calling SkeletonGraphic.AnimationState.SetAnimation, similar to the way you would in SkeletonAnimation?
アバター
Pharan

Pharan
記事: 5093

Affinity

Pharan さんが書きました:Yes, SkeletonGraphic is for use with Unity UI. It derives from UnityEngine.UI.MaskableGraphic so it works with Unity's UI.

What do you mean by "not able to play animated clips of the skeleton"?
Are you calling SkeletonGraphic.AnimationState.SetAnimation, similar to the way you would in SkeletonAnimation?
No. Not yet.
Since I was new to this specific component I was testing things out with only inspector manipulation.
If the component still should play clips of the skeleton without any script control but only with inspector manipulation, then I assume I am doing something wrong.

However, am I able to use SkeletonUtility + SkeletonUtilityBone just as I would to with SkeletonAnimation?
Because of the latter I had to use SkeletonAnimation in replacement for SkeletonGraphic.
Affinity
記事: 28

Pharan

SkeletonUtility doesn't work with SkeletonGraphic.

If you can describe your more specific need though, we can maybe come up with a solution, especially if SkeletonGraphic is really the better option for you.
アバター
Pharan

Pharan
記事: 5093

Affinity

Pharan さんが書きました:SkeletonUtility doesn't work with SkeletonGraphic.

If you can describe your more specific need though, we can maybe come up with a solution, especially if SkeletonGraphic is really the better option for you.
I don't know if the specific component is SkeletonGraphic that I want, but whatever works I'm fine with it.
However, since SkeletonGraphic seemed to be the current go-to component for UI element it not utilizing SkeletonUtility was a big con(only if SkeletonGraphic is really the recommended component for UI).
I'm attaching my HUD design and following with what I'm up to with the 'red section of the HUD.'

Basically, the HP bar is a combination gauge and icon.
Icons are the actual HP like hearts in Zelda, and the gauge just modifies its length and gap distances according to those Icons.
Icons must be attached to the right gap, and for that utilizing a bone as an anchor is a very efficient solution. And because in cases of like this(UI utilizing bones) I'm very confused of SkeletonGraphic's purpose and stuck to SkeletonAnimation as I've been always doing with any other character rigs.
添付ファイル
UI_Demo.png
Affinity
記事: 28

Pharan

a. You probably want the BoneFollowerGraphic component (you can create one by right-clicking on your SkeletonGraphic inspector and choosing "Add BoneFollower GameObject").

b. Or better yet, your own script that positions your icons only as needed.

If the icon transform is the child of your SkeletonGraphic transform, it's a straightforward assignment.
float scale = canvas.referencePixelsPerUnit;
Spine.Bone bone = skeletonGraphic.Skeleton.FindBone("your bone name");
iconTransform.localPosition = new Vector3(bone.worldX * scale, bone.worldY * scale, 0f);
This is basically what BoneFollower does.
It's also what SkeletonUtility does, but in hierarchy form, which can be slightly more computationally wasteful, depending on the situation.
アバター
Pharan

Pharan
記事: 5093


Return to Unity