otez

I have a SkeletonGraphic component with multiple canvas renderers enabled on a ScrollView. The animation disappears when its SkeletonSubmeshGraphics go out of viewport (which is correct). But the problem is that SkeletonSubmeshGraphics have 100x100px size and they disappear earlier then the rest of animation. Looks like a bug to me.
Please, fix it or help me find a workaround.
User avatar
otez
  • Posts: 3

Harald

Thanks for reporting and sorry for the trouble! We have committed a bugfix for this issue to the 4.0 branch. Hitting the Match RectTransform with Mesh - Match button will now assign the same bounds at each SkeletonSubmeshGraphic object.

A new spine-unity 4.0 unitypackage is available for download here as usual:
Spine Unity Download
Please let us know if this fix resolves your issue as well.

Issue ticket URL for later reference:
https://github.com/EsotericSoftware/spine-runtimes/issues/1983
User avatar
Harald

Harri
  • Posts: 3575

otez

Thank you a lot! It works, but not the way I think it was supposed to.
Let me give you an example of how I intend to use it.
I have an empty SkeletonGraphic object and a set of skeleton data assets. When the menu becomes active I initialize SkeletonGraphic with needed skeleton data. In order to make it work I have to initilize it like this:
anim.skeletonDataAsset = data;
anim.allowMultipleCanvasRenderers = true;
anim.startingAnimation = "animation";
anim.Initialize(true);
anim.Update(0);
anim.MatchRectTransformWithBounds();
Because if I don't do it in that exact order the submeshes won't apply rectangle bounds and get NaNs.
Probably, Update(0) and MatchRectTransformWithBounds() should be called inside Initialize method.
And what if I want to change the size of SkeletonGraphic object? Or if I want it to be exactly 1920x1080 and not the size of animation?
Or am I using SkeletonGraphic in a wrong way?
User avatar
otez
  • Posts: 3

Harald

otez wrote:Because if I don't do it in that exact order the submeshes won't apply rectangle bounds and get NaNs.
Could you please describe which order would lead to this problem (and still make sense)?
otez wrote:Probably, Update(0) and MatchRectTransformWithBounds() should be called inside Initialize method.
While Update(0) could theoretically be called in Initialize(), there are many cases where this will lead to Update() being called twice after initialization. While we could add an update = false parameter to the Initialize() method, it's not a big gain while introducing redundancy.

MatchRectTransformWithBounds should not be called automatically in Initialize, at least not every time. Again, an additional parameter could be added to Initialize(), but for the same reasons we are rather against doing that.

Please let me know if I misunderstood you there and you meant something else.
otez wrote:And what if I want to change the size of SkeletonGraphic object? Or if I want it to be exactly 1920x1080 and not the size of animation?
We are planning to implement better scaling and RectTransform support, see this issue ticket here:
https://github.com/EsotericSoftware/spine-runtimes/issues/1640
Unfortunately we didn't get to this issue ticket yet.
User avatar
Harald

Harri
  • Posts: 3575

otez

Harald wrote:Could you please describe which order would lead to this problem (and still make sense)?
This happens if I don't call Update(0) right after initialization. Mesh bounds don't get updated and it gives zero size, which eventually leads to NaN for subsmeshes.
Harald wrote:We are planning to implement better scaling and RectTransform support
Oh, that would be wonderful! Good to know that you are at least aware of that issue.

Thank you a lot!
User avatar
otez
  • Posts: 3

Harald

otez wrote:This happens if I don't call Update(0) right after initialization. Mesh bounds don't get updated and it gives zero size, which eventually leads to NaN for subsmeshes.
I see, thanks for the info. While normally Update(0) will be performed by the following Unity Update() callback hook, this would indeed require an intermediate Update() call. We have just pushed a commit that issues this Update(0) call automatically.

A new 4.0 spine-unity unitypackage is available for download here as usual:
Spine Unity Download
Please ley us know if this resolves you issue as well.
User avatar
Harald

Harri
  • Posts: 3575


Return to Unity