sirob

Hello!

I've come across an error with a certain spine skeleton when using a SkeletonPartsRenderer to display it in Unity, with tangents enabled. Unity errors due to a tangent array being assigned to the mesh which has a different size to the verts.

In this skeleton certain slots/images have been keyed as 'off' in some of the animations, and the draw order is being manipulated per-animation (I'm not sure which of these factors is the actual cause, but I believe it's one of them). The error is occuring when swapping animations in Unity (even in editor when not playing).

Having looked into the code, it seems to me that issue lies in SkeletonPartsRenderer.cs : RenderParts().

When it applies the geometry information to the mesh, it checks to see if the mesh generator has no verts, and, if so, it triggers a mesh.Clear(). However, after this it then calls meshGenerator.FillLateVertexData() which applies a tangent array (the size of the vert buffer) to the mesh. However, with the mesh being cleared, it has zero verts, and Unity errors because the size of the tangent array does not match that of the vert buffer applied to the mesh. (Even in the case where there are no verts, the vert buffer, and therefore the tangent buffer, have non-zero size).

I have managed to resolve this by moving the call to meshGenerator.FillLateVertexData() up into the else before it, meaning it only runs when the mesh has not just been cleared.

I would appreciate getting a more experienced perspective on the issue / my fix as I've not spent a huge amount of time in the Spine code and could be missing something here.

Thanks!
sirob
  • Сообщения: 5

Harald

Hello and thanks very much for this detailed writeup!

Unfortunately I did not get to this error when reproducing the setup you described. Are you using an up to date version of the Spine unity runtime?
If yes, could you please send me a zipped package of a minimal Unity project that shows this problem and send it to contact@esotericsoftware.com, that would help us a lot in fixing this issue!
Аватара пользователя
Harald

Harri
  • Сообщения: 1105

sirob

Thanks for your reply Harald.

I've just sent through a repro project to that email address.
sirob
  • Сообщения: 5

Harald

Thanks very much for the repro package!

I just tested it but strangely I did not get any error, scene tested: 'Character_Edit.unity', with bool 'Fix Applied' enabled or disabled - no error with either. Used Unity 5.6.6f2, as your included ProjectSettings directory suggested.

I also closed and re-opened the project with the same scene active, still no error. Do you always get an error upon startup, or upon loading the scene? Are you using the same Unity version?

---

Ah! I just changed the Animation Name parameter and finally got the error to appear! So no further actions needed by you, I can finally reproduce and fix the problem! Thanks again!
Аватара пользователя
Harald

Harri
  • Сообщения: 1105

sirob

Thanks for giving it a go.

I follow these steps:

1. Open Unity project
2. Open Character_Edit.unity scene
3. Click on the skeleton in hierachy "Spine GameObject"
4. In the inspector view on the SkeletonAnimation component, change the animation from B to A
5. See error

--
D'oh, I sent this just before your edit. Thanks :)
sirob
  • Сообщения: 5

Harald

You can subscribe to the issue's ticket here: [unity] SkeletonPartsRenderer mesh tangent error · #1265

---

Oh, just saw your other post - thanks for the repro step clarification anyway! :)

---

Thanks again for your great writeup above! The bug is now fixed.

Your suggested code change was correct, furthermore I resolved another related potential problem with mesh tangents and normals, which could be discovered thanks to your report.

You can download the latest package here as usual:
Spine Unity Download
Аватара пользователя
Harald

Harri
  • Сообщения: 1105


Вернуться в Bugs