• Unity
  • Clickable skeletonGraphic

Related Discussions
...

Hello guys, little issue: in my UI I have some SkeletonGraphics that are checked as RaycastTarget but they never fire mouse event (like OnPointerEnter). Two questions:

  1. Is it a problem on my end or is it just not possible to mouse interact with SkeletonGraphic?
  2. If not, how could I grab the SkeletonGraphic size so I can setup a transparent clickable area of equivalent size on top of it? (for SkeletonAnimation I normally catch size with
    meshFilter.mesh.bounds
    but that doesn't work with SkeletonGraphic)

Hello! I have quickly tested it and it does interact at my local setup. Please note that the RectTransform rectangle is used for any inside/outside tests. So it's not the actual form or mesh bounds of your SkeletonGraphic sprite (also not respecting transparent areas of course), but the UI element dimensions.

Gotcha, thanks for your answer and for testing. Would you know then how I could grab the SkeletonGraphic size so I can setup its RectTransform parent to match its size? Can't seem to find the property.

You can query the bounds of a SkeletonGraphic component via the following code:

var skeletonGraphic = this.GetComponent<Spine.Unity.SkeletonGraphic>(); // move line to Awake of course
var bounds = skeletonGraphic.GetLastMesh().bounds;

Works as a charm, thanks!

Great to hear, thanks for letting us know!