• RuntimesUnity
  • Attachment shows surrounding sprites in Unity, but not in Spine

  • Изменено

For some reason same attachment looks correct in spine, but after importing into Unity, it works too. But all sprites near it from atlas are shown too. Atlas was unchanged, just positions of attachment were modified, but as far as I can remember it should not break anything, just moving attachments in editor. Any Idea what could be the root cause of such behavior?


  • Harald ответили на это сообщение.
    Related Discussions
    ...

    The issue you're experiencing where surrounding sprites from the atlas are shown in Unity but not in Spine could be due to several factors. Here are some potential causes and solutions based on the provided contexts:

    1. Atlas Texture Modification:

      • Ensure that the atlas texture was not modified after being exported from Spine. If it was, this could lead to discrepancies between the Spine Editor and Unity. If the texture was modified, try re-exporting the atlas from Spine without any modifications.
    2. Atlas Export Settings:

      • Check the atlas export settings in Spine. Ensure that the settings used for exporting the atlas are consistent and correct. For example, using the Rectangles packing setting instead of Polygons might help avoid issues with missing or incorrectly mapped regions.
    3. Texture Import Settings in Unity:

      • Verify the texture import settings in Unity. Ensure that the settings match the export settings from Spine. Specifically, check if the Power of Two setting is set to None and that Tight Packing is disabled if you are using Unity's SpriteAtlas.
    4. Attachment Naming and Path:

      • Ensure that the attachment names and paths in Spine match those in the atlas file. Any discrepancies in naming or paths can lead to issues where the wrong regions are displayed.
    5. Whitespace Stripping:

      • If whitespace stripping was applied during the atlas export, it might affect the perceived pivot and alignment of attachments. Ensure that the pivot is correctly set and that the useOriginalRegionSize parameter is used if necessary.
    6. Shader and Material Settings:

      • Check the shader and material settings used in Unity. Ensure that the correct shader is applied and that there are no issues with transparency or culling settings.

    Here are some steps you can take to troubleshoot and resolve the issue:

    1. Re-export the Atlas:

      • Re-export the atlas from Spine with consistent settings and without any modifications to the texture.
    2. Check Import Settings:

      • Verify and adjust the texture import settings in Unity to match the export settings from Spine.
    3. Review Attachment Names:

      • Ensure that the attachment names and paths in Spine match those in the atlas file.
    4. Test with Different Packing Settings:

      • Try exporting the atlas with different packing settings (e.g., Rectangles instead of Polygons) to see if it resolves the issue.
    5. Inspect Shader and Material:

      • Check the shader and material settings in Unity to ensure they are correctly configured.

    If the issue persists, you might want to create a minimal version of the project that reproduces the problem and share it for further investigation.


    Well... after making this mesh more tight it is gone. Also replacing mesh with just regular sprite works too. I am just wondering, if it should work with not-tight mesh too. Or Spine do not automatically trim meshes if mesh grid is defined more large that in atlas? For some reason I have tought it is the case. But at least it will be auto trimmed for sprites.

    • Harald ответили на это сообщение.

      Maltakreuz Atlas was unchanged, just positions of attachment were modified, but as far as I can remember it should not break anything, just moving attachments in editor.

      What do you mean by "positions of attachment were modified", did you just move the attachments in the Spine Editor relative to the bone (so change the position or rotation offset)? Or did you mean something else?

      But all sprites near it from atlas are shown too.

      What do you mean by "all Sprites", other attachments that have been packed to the atlas texture?

      Maltakreuz Also replacing mesh with just regular sprite works too

      By "regular Sprite" do you mean using a Region Attachment instead of a Mesh Attachment (disabling "Mesh" at the attachment) in the Spine Editor?

      What would explain the issue is if you have exported the atlas separately from the skeleton without specifying the Spine project during atlas export, and whitespace stripping is removing whitespace which you need in your Mesh Attachments. You can specify the Spine project via:

      -j or --project Path to a project to determine which images are used by meshes.

      See the documentation here.

      • Maltakreuz ответили на это сообщение.

        Harald What do you mean by "positions of attachment were modified", did you just move the attachments in the Spine Editor relative to the bone (so change the position or rotation offset)? Or did you mean something else?

        Yes, just moving attachments in editor.

        Harald What do you mean by "all Sprites", other attachments that have been packed to the atlas texture?

        I mean I can see anything else from sprite atlas that fits in this defined by mesh rectangle. So not just staff, as desired, but all other tightly packed nearly placed things like arrows etc.

        Harald By "regular Sprite" do you mean using a Region Attachment instead of a Mesh Attachment (disabling "Mesh" at the attachment) in the Spine Editor?

        Yes, exactly. Btw. Original sprite has empty space at borders, but this effect with drawing surrounding sprites does not happen using region attachment.

        Yes, I only export spine skeleton. I can not do repack atlas anymore, as I have 9 2k sprite atlasses and only 100mb free in git. But as i did not modified any sprites it should work and actually works.

        Well... at least making tight mesh worked for me. Just wanted to understand in details why it happens at all.

        • Harald ответили на это сообщение.

          Maltakreuz Yes, exactly. Btw. Original sprite has empty space at borders, but this effect with drawing surrounding sprites does not happen using region attachment.

          Region attachments automatically contract accordingly to compensate for whitespace stripping. Mesh Attachments can't do that.

          Maltakreuz I can not do repack atlas anymore, as I have 9 2k sprite atlasses and only 100mb free in git.

          I don't quite understand the problem here.

          Maltakreuz But as i did not modified any sprites it should work and actually works.
          Well... at least making tight mesh worked for me. Just wanted to understand in details why it happens at all.

          Glad to hear.