• Unity
  • BoneFollowerGraphic Confusion When No RectTransform

  • Изменено
Related Discussions
...

This is a small thing, but it really confused me.

I wanted a particle effect to follow a bone of a SkeletonGraphic. So I created the GameObject, setup my particle effect and dragged it to the right spot in the Canvas's object hierarchy, added the BoneFollowerGraphic script and selected the right bone.

I ran my game, and the script wasn't positioning the effect!

The problem, if you missed it in my step-by-step description: I had created the effect's GameObject outside the canvas and dragged it in, so it didn't get a RectTransform, and BoneFollowerGraphic has this bit in it:

var thisTransform = this.transform as RectTransform;
if (thisTransform == null) return;

I don't think this should fail silently! It's a bit confusing for such an easily made mistake in a legitimate workflow. Either it should AddComponent<RectTransform> (which just replaces Transform with RectTransform) or, if that would have unexpected/unhelpful side effects, print a loud warning in the Console that explains what's going on.

Or even a warning in the BoneFollower Inspector that says "hey, this has a Transform and not a RectTransform, you should add one."

Good catch, thanks for reporting!

This issue has just been fixed. There is now an added RequireComponent(typeof(RectTransform)) which should prevent this problem from happening again.

A new 3.8 unitypackage is available for download here as usual:
Spine Unity Download: Download

Issue ticket for reference:
https://github.com/EsotericSoftware/spine-runtimes/issues/1828

Thanks Harald!

Welcome back from your break, and well done working your way through all the threads!

Thanks! :nerd: Hope you've had some nice Christmas holidays, and a happy new year! 🙂