• RuntimesUnity
  • Spine atlas asset deletes materials when material content updates

I'm using Unity with spine assets, in URP. The characters use a designated material made with shadergraph and the material is applied within the designated Spine Atlas Asset.

This material functionality works perfectly fine in terms of functionality. I can edit the parameters such as specific colours perfectly fine, and I can adjust which graphic it uses too. However, if I were to change a setting on, or fully reimport, the mainTex art asset, the custom material gets fully deleted, and the Spine Atlas Asset switches to using the default generated material instead.

When the custom material doesn't have an asset with the correct name in the mainTex slot, it throws a few errors, so perhaps that has something to do with it. Maybe when the material is being refreshed due to the asset updating, some check doesn't see the asset as existing and thus hits an eject button. That's my current theory for the situation at least.

I am working in unity 6000.0.32f1
and using spine installed with the package called: spine-unity-4.2-2024-09-12

Changing settings on the art asset throws logs in the chat:

Player Character Purple_Final_Atlas :: Imported with 1 material
UnityEngine.Debug:Log (object,UnityEngine.Object)
Spine.Unity.Editor.AssetUtility:IngestSpineAtlas (UnityEngine.TextAsset,System.Collections.Generic.List`1<string>) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:733)
Spine.Unity.Editor.AssetUtility:ImportSpineContent (string[],System.Collections.Generic.List`1<string>,bool) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:403)
Spine.Unity.Editor.AssetUtility:HandleOnPostprocessAllAssets (string[],System.Collections.Generic.List`1<string>) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:118)
Spine.Unity.Editor.SpineEditorUtilities:OnPostprocessAllAssets (string[],string[],string[],string[]) (at Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs:102)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

and also:

Changes to 'Assets/Characters/Player1/Player Character Purple_Final.json' or atlas detected. Clearing SkeletonDataAsset: Assets/Characters/Player1/Player Character Purple_Final_SkeletonData.asset
UnityEngine.Debug:LogFormat (string,object[])
Spine.Unity.Editor.AssetUtility:ReloadSkeletonData (string,Spine.Unity.SkeletonDataCompatibility/CompatibilityProblemInfo) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:578)
Spine.Unity.Editor.AssetUtility:ImportSpineContent (string[],System.Collections.Generic.List`1<string>,bool) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:419)
Spine.Unity.Editor.AssetUtility:HandleOnPostprocessAllAssets (string[],System.Collections.Generic.List`1<string>) (at Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:118)
Spine.Unity.Editor.SpineEditorUtilities:OnPostprocessAllAssets (string[],string[],string[],string[]) (at Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs:102)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    Related Discussions
    ...

    The issue you're experiencing with the Spine atlas asset deleting custom materials when the main texture is updated or reimported is likely related to how Unity handles asset re-imports and the Spine-Unity integration. When you update or reimport the main texture, Unity triggers a re-import process for the associated Spine assets, which can reset the material assignments to their default settings. This behavior is often due to the Spine-Unity runtime's automatic handling of materials, which may not recognize custom materials if they don't match expected naming conventions or settings.

    To address this, ensure that your custom material is correctly set up to match the expected settings for the Spine-Unity runtime, particularly regarding the alpha settings (Premultiplied vs. Straight Alpha). You can refer to the Spine-Unity documentation for guidance on setting up materials correctly. Additionally, consider creating a script or editor extension to reassign your custom material after re-imports automatically, as this can help maintain your desired material settings without manual intervention.

    zepht However, if I were to change a setting on, or fully reimport, the mainTex art asset, the custom material gets fully deleted, and the Spine Atlas Asset switches to using the default generated material instead.

    Sorry to hear you're encountering issues!
    Please note with spine-unity-4.2-2024-09-12 you're using a spine-unity package which is already half a year old, with many bugfixes released in the meantime. Could you please check whether the same issue still persists with the latest spine-unity 4.2 runtime package?

    What is your general export and import procedure, do you perhaps export your skeletons right into the target Unity directory? Where do you place textures in relation to the skeleton data asset in your Unity project? Could you please share some reproduction steps how we can reproduce this issue? Or could you share a minimal Unity reproduction project which still shows this issue upon reimport? You can send us your project as a zip file to contact@esotericsoftware.com, briefly mentioning this forum thread URL, then we can have a look at what's going wrong.

    20 jours plus tard

    Hello, apologies for the delay, things have been busy.

    I have updated my project via downloading the latest version from the attached link, and then by dragging it into unity and hitting apply on the import, then proceeded to close and reopen the project just in case.

    Unfortunately this did not resolve the issue.


    All of the relevant files are in this same folder together and are as follows:

    • Mat Custom - my custom shader graph material
    • Mat Lit - A default unity URP lit material
    • [name].json
    • [name].png
    • [name].atlas.txt
    • [name]_Atlas.asset
    • [name]_Material.mat
    • [name]_SkeletonData.asset

    I've checked and the issue persists equally for both a custom and a lit shader, changing any setting on the png deletes the material if it is assigned within the Materials collection on the Atlas.

    In terms of reproduction steps:
    I import the files by dragging the .atlas.txt , .png and .json (exports received from our spine artist), into the unity folder seen above. The remaining [name] assets get automatically generated and then i create new materials to test with. I then assign the relevant texture to the material and assign the material to the Materials collection on the atlas as seen above. Making ANY change to the .png settings and hitting Apply then deletes that material entirely and replaces the material in the Materials collection on the atlas with the default generated material.

    When i refer to the settings on the texture, I mean it on this window.

    So far I am getting the exact same results between two separately constructed projects. If you would like me to provide further information, or deem that it would be better if i share a minimal project after all then do please let me know.

    @zepht Thanks for reporting and sharing the reproduction steps! We could indeed reproduce this issue. We've just pushed a bugfix to the 4.2 branch. A new spine-unity 4.2 unitypackage is available for download:
    https://jp.esotericsoftware.com/spine-unity-download

    Issue ticket URL for later reference:
    EsotericSoftware/spine-runtimes2793

    Please let us know if this resolves the issue on your end as well.

      Harald Thanks for the quick resolution! I've updated my files and it appears to function as intended now!

      @zepht Glad to hear it helped, thanks for checking!