• RuntimesUnity
  • unity 场景里有多个Spine做的小怪(同一种),当小怪的数量增加时,性能会非常的耗,FPS也疯狂的下降,想要咨询下Spine怎么合批和管理。




这时性能截图,当多个Spine在场景里,他们没有合批,而且他们的SkeletonAnimation的Updata和LataUpdata很耗时

    Related Discussions
    ...

    在Unity场景中,如果有多个Spine动画的小怪,随着数量增加,性能会显著下降。以下是一些优化和合批管理的建议:

    1. 减少顶点变换:确保你的骨架没有过多的顶点变换。可以使用“修剪”功能来减少顶点变换。参考链接:修剪

    2. 合并皮肤:在运行时只加载和合并当前使用的皮肤,而不是所有皮肤。参考链接:Combining Skins

    3. 减少更新频率:可以考虑每帧只更新一部分骨架,而不是全部骨架。例如,可以采用轮询方式更新骨架。参考代码:

         // with three skeletons:
         1, 2, 3, 1, 2, 3, 1, 2, 3, ..

      参考链接:RenderExistingMesh

    4. 使用现有网格渲染:对于大量相同的骨架,可以只动画化少量骨架,并使用这些姿势来渲染更多的骨架。参考链接:RenderExistingMesh

    5. 性能优化文档:参考Spine的性能优化文档,了解更多优化技巧。参考链接:性能优化

    6. 减少材质和纹理切换:确保你的材质和纹理尽可能少地切换。可以通过合并纹理图集来减少切换次数。

    通过以上方法,可以显著提高多个Spine动画在Unity场景中的性能。

    • lxw respondió a esto

      Spinebot 顶点已经优化过的,皮肤只有一个原皮肤,材质也只有一个,减少更新频率和使用现有网格渲染怎么使用,而且Spine小怪有自己的逻辑交互会改变动画和材质,这会影响吗

      Spinebot RenderExistingMesh 没有这个组件,我用的时Spine3.8

        lxw 这时性能截图,当多个Spine在场景里,他们没有合批,而且他们的SkeletonAnimation的Updata和LataUpdata很耗时

        If all your Spine skeleton animation and mesh updates for 72 skeletons take up 0.73 and 0.48 milliseconds, why do you consider this bad? This would result in a theoretical framerate of 826 fps. Every skeleton will be animated, unless you skip updates as Spinebot mentioned above. There is an example scene Spine Examples/Other Examples/FixedTimestepUpdates which shows how to update every N frames.

        Regarding batching: If your skeletons are not batched, this is likely your main problem if you see a bad framerate. Are you perhaps using Universal Render Pipeline (URP)? If not and your skeletons are not batched, you may have too many vertices for Unity's dynamic batcher limits of 900 vertex attributes / 300 vertices (see the documentation here).

        In general please see the FAQ on performance:
        https://zh.esotericsoftware.com/spine-unity#%E6%80%A7%E8%83%BD%E9%97%AE%E9%A2%98

        lxw Spinebot RenderExistingMesh 没有这个组件,我用的时Spine3.8

        3.8 is already several years old. If you need the RenderExistingMesh example component, you should still be able to integrate it from a newer spine-unity runtime like 4.2 into your 3.8 project.