The sorting issue you're experiencing occurs because SkeletonAnimation and SkeletonMecanim components use a MeshRenderer rather than a SpriteRenderer. Unlike SpriteRenderer, which has an explicit Sprite Sort Point setting, MeshRenderer doesn't provide a customizable sort point parameter and defaults to using the mesh bounds center for sorting.
Solution: Use a SortingGroup Component
The recommended solution is to add a SortingGroup component to your Spine skeleton GameObject (or its parent). When you add a SortingGroup, Unity will use the Transform's pivot point for sorting instead of the mesh center, which should give you the consistent behavior you're looking for with your Y-position-based sorting.
Steps:
- Select your Spine skeleton GameObject
- Add a
SortingGroup component via the Inspector
- The skeleton should now sort based on its Transform pivot, just like your regular sprites
Additional Considerations:
- Make sure your regular sprites also have their
Sprite Sort Point set to Pivot (not Center) in the SpriteRenderer settings for consistency
- If you're using Unity's graphics settings with a Y-axis custom sorting, ensure your Z positions are set appropriately
- The
SortingGroup will treat the entire skeleton as a single sorting unit based on the pivot point
This approach should give you the sorting behavior you need for your top-down game, with both Spine characters and regular sprites sorting consistently based on their pivot points and Y positions.