• Runtimes
  • Unity: Material constantly removed and added with SkeletonMecanim

I am using the Unity runtime for Spine and have run into an issue. Can I please have help with it?

The problem I am having is that, when I set up a Spine skeleton with an instance of the SkeletonMecanim renderer, it appears that something tries to remove the material on the Mesh Renderer every update, while something else tries to add the material. The result is that the Unity editor's performance drops dramatically, and the Spine sprite quickly alternates between being visible and invisible. In addition, this behavior is present at runtime, so in play mode, the sprite is mostly invisible, but parts of it flicker on the screen. In both the editor and in play mode, I can select the sprite in the Inspector and see the material being added and removed from both the sprite's Game Object and the Mesh Renderer's materials list.

This is a difficult behavior to describe in words, so I took a screen recording. One thing that stands out to me is that this behavior does not start until I add the Animation Controller to the Animator component.

https://www.dropbox.com/s/hcapr93axgvgptq/Material%20being%20removed%20and%20readded%20in%20Esoteric%20Software%20Spine.mp4?dl=0

Can I please have help understanding how to resolve this issue?

I am using Unity 2021.3.14f1 and Spine Unity runtime 4.0.49 4.0.0. I don't have the Spine editor myself, but rather am using a package of sprites that I purchased from the Unity asset store: https://assetstore.unity.com/packages/2d/characters/4direction-animated-2d-monsters-fantazia-top-down-216312

  • Harald ha risposto a questo messaggio
    Related Discussions
    ...

    KevinNorth I don't have the Spine editor myself, but rather am using a package of sprites that I purchased from the Unity asset store:

    Please note that if you integrate any of the Spine runtimes (spine-unity in your case) in your project (your game), you need to own a valid Spine license to do so.

    The result is that the Unity editor's performance drops dramatically, and the Spine sprite quickly alternates between being visible and invisible.

    Sorry to hear you're having troubles! Could you please send us a minimal Unity project that still shows this issue? You can send it as a zip package to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context.

    13 giorni dopo

    I'm sorry I took so long to reply. My day job has been busy lately. I appreciate the help!

    I sent an email to contact@esotericsoftware.com with a minimal project that shows the issue.

    Thank you for letting me know I need to have a Spine license to use the runtimes. Thank you also for offering me support before I had bought one! I have now purchased an Essential license.

    @KevinNorth Thanks for sending the reproduction project. Please note that you should in general delete the unnecessary Library directory before packing a zip package, as this will save 95% of the file size.
    We will get back to you here on the forum as soon as we've figured out what's going wrong.

    KevinNorth The result is that the Unity editor's performance drops dramatically, and the Spine sprite quickly alternates between being visible and invisible.

    Unfortunately we could not reproduce this issue with your reproduction project, we see only an invisible skeleton. Are you perhaps using an old version of the spine-unity 4.0 runtime? Please have a try updating the spine-csharp, spine-unity and spine-unity-examples UPM packages via the Unity Package Manager by hitting the Update button at each package.

    KevinNorth In addition, this behavior is present at runtime, so in play mode, the sprite is mostly invisible, but parts of it flicker on the screen.

    We see in your project a strange skeleton setup of having separate skins for Back, Front and Side orientation, which is not recommended in general as it has several drawback, one of which follows shortly. At the same time, you are blending animations Back_Idle, Front_Idle and Side_Idle in a blend tree node in the Animator Controller. This in combination with separate skins for orientation is not good design, as it will make your character invisible whenever skin and animation don't match.

    Why don't you use a single skin for all orientations and let the animation decide which slots and attachments are visible? This way you would never end up with an invisible character upon mismatch and could also use Skins for what they are intended to be used for, like switching the appearance of your skeleton (e.g. clothing).

    Unfortunately we could not reproduce this issue with your reproduction project, we see only an invisible skeleton. Are you perhaps using an old version of the spine-unity 4.0 runtime?

    Thanks for letting me know. I'll try your other suggestions first, but if I still can't get it working, I'll try to create another project that truly does replicate the issue. If nothing else, it will help me better understand the issue myself.

    I'm using the 4.0.0 version of the runtime, but clicking the "Update" button doesn't change the version. Is there another way to try updating to a newer 4.0.x? I added the UPM packages via the Git links, i.e. https://github.com/EsotericSoftware/spine-runtimes.git?path=spine-csharp/src#4.0.

    At the same time, you are blending animations Back_Idle, Front_Idle and Side_Idle in a blend tree node in the Animator Controller. This in combination with separate skins for orientation is not good design, as it will make your character invisible whenever skin and animation don't match.

    Why don't you use a single skin for all orientations and let the animation decide which slots and attachments are visible?

    This sounds like it could potentially be the root of my problem. I programmed the entity using the sprite to move in random directions, so the blend trees are almost always in-between values. I didn't create the sprite myself, though, so this will be my first time editing a Spine sprite!

    I tried looking through the documentation to see if there's any hints on removing skins while keeping their animations, but there's a lot to digest. Can you please point me to the docs that would be the most helpful for rolling up my sleeves and editing the sprite to see if doing so resolves my issue?

    (Ultimately, I'm planning on asking the asset creator to help me. But I would like to make sure this really is the right solution before asking them if they're willing to spend so much time editing their sprites for me.)

    Thank you again for all of your help!

    • Harald ha risposto a questo messaggio

      KevinNorth I'm using the 4.0.0 version of the runtime, but clicking the "Update" button doesn't change the version. Is there another way to try updating to a newer 4.0.x? I added the UPM packages via the Git links, i.e. https://github.com/EsotericSoftware/spine-runtimes.git?path=spine-csharp/src#4.0.

      The package version number of the spine-unity runtime packages is always left at just 4.0.0 or 4.1.0, please ignore the unchanged patch version number. This is because the downloadable unitypackage is still our primary form of publishing updates to the spine-unity runtime. The initial reason was to avoid confusion of having multiple version numbers for the same package status, being e.g. 4.1-2023-04-13 and 4.1.15. Nevertheless, reconsidering the situation, it may be the better option to just increase the package version number with each release as well. Thanks for bringing our attention to the subject! We will update our packaging workflow accordingly soon.

      KevinNorth I programmed the entity using the sprite to move in random directions, so the blend trees are almost always in-between values. I didn't create the sprite myself, though, so this will be my first time editing a Spine sprite!

      Please note that the author of the skeleton seems to not have intended blended playback of animations if the skeleton is created with separate skins per direction. Likely the animations might look strange when played back with e.g. 60% weight.

      KevinNorth I tried looking through the documentation to see if there's any hints on removing skins while keeping their animations, but there's a lot to digest.

      What do you mean by "removing skins while keeping their animations"? This sentence does not make a lot of sense, since skins don't contain animations. Skins are sets of attachments for skin-placeholders. They are completely independent of animations.

      KevinNorth Can you please point me to the docs that would be the most helpful for rolling up my sleeves and editing the sprite to see if doing so resolves my issue?

      Please check out the Spine User Guide here, especially the pages of the Getting Started section:
      http://esotericsoftware.com/spine-user-guide
      You should not take shortcuts around getting to know the basics first, otherwise it will lead to a lot of frustration and wasted time when not understanding how skins, slots, attachments, animations and the like work.