suntabu đã viếtWe are using SkeletonAnimation and the problem happens in SkeletonAnimation, besides SkeletonGraphic and SkeletonAnimation's mesh rendering are not same, so I don't want to dig SkeletonGraphic performance results in wasting time. The only thing is I wanna reduce the count of vertices when spine rendering.
While MeshRenderer
and CanvasRenderer
are different of course, I meant that similar changes (one Mesh with a shared vertex buffer, vs. multiple Meshes with separate vertex buffers) will very likely result in similar benefits or drawbacks.
suntabu đã viếtI'm not a newbie in unity, I know how unity mesh filter works, how submesh works and why this issue happens. Why I ask you about how to set multiple meshes to mesh filter is just because I don't understand your suggestion and why you suggest this.
I assume I misunderstood you there. I repeatedly understood that you wanted to know how to assign more than one vertex buffer per Mesh
/ MeshFilter
(one vertex buffer per submesh), and I kept repeating that this is impossible, and that you need separate Meshes if you want separate non-shared vertex buffers. Therefore I suggested having a look at how SkeletonGraphic
creates and fills separate meshes when Multiple Canvas Renderers
is enabled.
So I assume we simply misunderstood each other.
suntabu đã viết
At last, did you test the codes I upload in last post?
I had a look at it, but as you appended only a single .cs file, we could not test anything. In general if you want us to test something in Unity, please send us a Unity project as a zip package to contact@esotericsoftware.com.
suntabu đã viếtI fixed this bug by changing MeshGenerator.cs code:
Now I understand what the problem was. Thanks very much for pointing that out, good catch! This must have slipped through for such a long time, as this problematic codepath is only executed when clipping is enabled and multiple submeshes are used.
I have fixed it a bit differently, using an overloaded Mesh.SetTriangles()
method variant that allows to specify a length parameter in addition to the int[]
array. You can see it in this commit. This method overload only exists on Unity 2019.3 and newer versions, which Unity version are you using?
If you need to use an older Unity version, you could use the Mesh.SetTriangles(List<int>)
overload. Then you would change the line ExposedList<ExposedList<int>> submeshes
to ExposedList<List<int>>
and adjust the code similarly. This should then avoid some GC overhead.
A new 3.8 unitypackage has just been released, it can be downloaded here as usual:
Spine Unity Download
The bugfix will be merged to the 4.0-beta branch soon.
Please let us know if this resolves the problem for you as well.
For later reference: This issue has been tracked under this issue ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/1894