Unity Version: 2022.3.20f1
Spine Version: 4.2-2024-12-20
Spine URP Shaders Version: 4.2.39

I created a dash animation for characters, where the alpha value is adjusted to 0 after the dash starts and then restored to 1 shortly after, creating an effect where the character disappears and reappears.

However, with some characters, the following error message is displayed every frame whenever the alpha value is adjusted. (The animations were made in almost the same way for all characters, but some characters don’t have this issue, making it even more confusing.)

NullReferenceException: Object reference not set to an instance of an object
Spine.Unity.MeshGenerator.AddSubmesh (Spine.Unity.SubmeshInstruction instruction, System.Boolean updateTriangles) (at Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs:576)
Spine.Unity.SkeletonRenderer.LateUpdateMesh () (at Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs:628)
Spine.Unity.SkeletonRenderer.LateUpdate () (at Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs:589)
Spine.Unity.SkeletonAnimation.LateUpdate () (at Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs:291)

The animation itself works fine, but the error messages are very distracting, so I’d like to resolve this issue. What could be causing it?

    Related Discussions
    ...

    ddddddddddd This is not related to your question, but since you have chosen the "International" tag, feel free to post in your native language if English is not your first language.

    Our Unity expert Harald is currently on vacation, so it will take him some time to answer this question, but if possible, could you please create a minimal Unity project and email it to us so that we can reproduce the problem?:contact@esotericsoftware.com
    It would be helpful to investigate the cause when he gets back.
    Please include the URL of this forum thread in the email so we know the context. Then we can take a look at what's wrong.

    프로젝트를 이메일로 제출했습니다.

    새 프로젝트를 만들어 테스트를 해보다가, 'Use single submesh' 옵션을 활성화했을때만 이 문제가 발생하는 것을 확인했습니다. 머테리얼을 여러 개 사용할 것이 아니라면 이 옵션을 활용해서 최적화에 이점을 가져올 수 있다고 알고 있는데, 이 옵션에 최적화에 영향을 주는 것이 맞는지, 맞다면 어떻게 지금 문제를 해결하는 게 좋을지 알려주시면 감사하겠습니다.

      • Modifié

      ddddddddddd Thanks for sending us your Unity project files! I was able to confirm the problem, however, the package even included unnecessary files such as the Library folder, so if you are asked to send us a minimal Unity project again in the future, please remove them before sending it to us.

      It seems that the skeleton that is causing the error is using a clipping attachment, so if you enable the Use single submesh option of the SkeletonAnimation component in this state and do an alpha animation, it seems that the runtime tries to add a submesh and causes the error as it is prohibited by the option. In the case of your skeleton, it looked like you could adjust the mesh hull without using clipping so that the hair would not stick out of the hood, so you might want to try removing the clipping attachment. In fact, clipping in the Spine Runtimes is implemented using the CPU can be a very expensive operation, so it is better to avoid using it as much as possible in cases where it can be avoided.

      Unfortunately, I am not sure why adding a submesh is necessary when using clipping and alpha animation at the same time, so perhaps Harald will explain this when he returns.

      답변 감사드립니다. 다음에 프로젝트를 전송할 일이 생기면 꼭 해당 조치를 하도록 하겠습니다.

      clipping attachment가 비싼 작업이라면, 혹시 이를 쉽게 대체할 수 있는 방법은 원본 리소스 자체를 조정하는 것 외에는 없을까요? 동시에 등장하는 캐릭터 수가 많은 편이기 때문에 되도록이면 최대한 최적화가 되었으면 합니다.

        ddddddddddd By the original resource you refer to, do you mean the images used by the skeleton? At least for the skeleton included in the data you provided, it seemed that the image did not need to be changed, only the mesh hulls could be modified.

        Based on your information that there are many characters appearing in the scene at the same time, it is actually best to avoid using clipping attachments. However, if it is necessary, you can improve performance by setting the clipping attachment to be active only when you need to use it, rather than leaving it active all the time. For example, clipping attachments are often used to create blink animations, but even in this case, it is a good idea to keep the clipping attachment inactive while the eyes are open and activate it only when the eyelids are down.

        답변 감사드립니다. 이미지를 말씀드린 것이 맞습니다. 최적화를 위해서는 clipping attachment를 사용하기보다는 이미지를 잘라내는 쪽으로 수정하는 쪽이 낫겠네요.

        여러가지 고려 사항이 많겠지만, 모바일 환경에서 한 화면에 동시에 등장하는 최대 캐릭터 수를 일반적으로 몇 명 정도로 생각하면 좋을까요? 정확한 수치가 아니더라도 참고할 수 있을만한 값이 있으면 좋을 것 같습니다.

          ddddddddddd Unfortunately, it is difficult to answer the question about the maximum number of characters, since it depends on various factors, such as how complex the skeleton is and the resolution of the skeleton's textures. However, some users have in the past posted the results of their tests displaying a large number of skeletons, so you may want to look for such threads in this forum. For example, the following thread may be helpful:
          https://esotericsoftware.com/forum/d/15046-performance-analysis-of-mecanim-vs-animation

            6 jours plus tard

            Misaki
            여러가지 테스트를 해보다가 한 가지 더 질문이 생겼습니다. 제출했던 프로젝트에서도 동일하게 문제가 발생하는데, 동일한 캐릭터를 화면에 배치했을 때 배칭이 깨지며 frame debegger에 "Dynamic Batching is turned off in Player Settings or is disabled temporarily in the current context to avoid z-fighting"라고 표시됩니다. 이 문제는 어떻게 해결할 수 있나요?

              ddddddddddd
              아, Dynamic Batching이 되지 않고 있던 건 URP 세팅에서 비활성화가 되어있기 때문이라는 것을 확인했습니다. Preferences의 Core Render Pipeline에서 Additional Properties를 All visible로 설정해주지 않으면 아예 해당 옵션이 안 보이는 것이었네요.

              혹시 동일한 화면에 등장할 가능성이 높은 캐릭터들의 텍스쳐를 하나의 아틀라스로 묶어 배칭이 되도록 하는 건 불가능할까요? Spine-Skeleton 셰이더에는 아래와 같이 표시가 되고 있습니다.

                ddddddddddd It is possible to combine the texture atlases of multiple skeletons into one. There are several ways to do this:

                1. If the skeletons are grouped together in a single Spine project, they can be combined into a single atlas by selecting Single atlas in the export settings window.
                2. If you have separate Spine projects for each skeleton, you can still combine multiple skeletons into a single atlas by launching Texture Packer individually and specifying the folder containing the images to which the skeletons refer.
                un mois plus tard
                • Modifié

                ddddddddddd 혹시 동일한 화면에 등장할 가능성이 높은 캐릭터들의 텍스쳐를 하나의 아틀라스로 묶어 배칭이 되도록 하는 건 불가능할까요? Spine-Skeleton 셰이더에는 아래와 같이 표시가 되고 있습니다.

                If you see SRP Batcher Not compatible, you are likely using the wrong shader. When using URP, you need to use the respective Spine URP shader variants from the Spine URP Shaders extension package instead of the built-in Render Pipeline Spine shaders that come with the spine-unity package (with the exception of SkeletonGraphic and UI).
                See the documentation here about Spine shaders and here about Spine URP shaders.

                Instead of the Spine/Skeleton shader you should be using the Universal Render Pipeline/Spine/Skeleton shader, or Universal Render Pipeline/2D/Spine/Skeleton when using the URP 2D Renderer pipeline.

                Regardless, what Misaki wrote above still applies. If more than one skeleton's attachments fit on a single atlas texture, you may want to pack them together in order to be able to batch more than one skeleton type.

                @ddddddddddd I forgot to mention: Please note that SRP Batcher and the normal Unity batcher are mutually exclusive, and both have their benefits. You may want to evaluate which provides better results for you.