Keydus This is where I do not agree. It is not trivial since animations might (should I say must?) change the draw order almost every time. In our case, for example, it changes because when running we show the sole of shoes.
I just explained how you can change the draw order, which was what you asked how to do above:
"I thought that it might be trivial to set a specific rendering order for a given attachment."
I meant that you can directly modify the position of each slot, this is easy to do, just modify the Skeleton.DrawOrder
list accordingly. You seem to have meant "I want to set a draw order integer value and sort slots automatically based on this integer value".
Still I don't quite see why it would be so complicated to adjust the order in DrawOrder to get to a certain position, after a certain target slot or exchange it with a certain placeholder slot.
Anyway, I've always recommended against manually changing draw order since it's not as clean and maintainable as other solutions.
Keydus That's why I would recommend having template attachments which can be positioned cleanly in the Spine Editor, adjusted in draw order in animations and previewed to ensure everything is perfectly ordered. But it's up to you of course what you prefer and what your use case requires.
Yes and I don't like either this solution because it implies to adjust the draw order for every frame which seems to be quite bad for performances when dealing with multiples characters in the same spot.
Are you now talking about what I recommended with template attachments? This sounds as if you're still talking about the previous solution, which I recommended against. (As a side node, changing skeleton.DrawOrder
could be done very efficiently and would be much cheaper than e.g. splitting a skeleton into multiple GameObject parts.)
I recommended having multiple slots to automatically always have the right draw order for each type of equipment item (separate for F_hat
, F_hat-always-front
, B_hat
, B_hat-always-front
) and for each facing direction. You then don't have to change draw order ever. You author them correctly in the Skeleton first.
Keydus So, basically, if I summarize : there is no way to properly fix the draw order of a specific slot and so you can't tell in runtime that this slot must be rendered after (or before) everything else.
You are correct in that Spine slots are not sorted automatically by Sort Order
integers. Draw order is set explicitly (by design) to avoid having to sort anything by default. However just adjust Skeleton.DrawOrder
accordingly if you do want to sort slots differently. Moving certain slots completely to the front or back should be rather easy to implement. If you need utmost performance, you could reserve some empty placeholder slots at the front and back and then swap your desired equipment item slots there.
Alternatively you could also modify the source code of Slot
and add a int sortingOrder
property which you can then read and apply sorting accordingly.
Also if you're concerned about performance of altering DrawOrder
(which will not be measurable, but still), you could modify the source code and add a callback to Spine.DrawOrderTimeline
which is called when the draw oder is actually modified, so you can only update when the draw order changes. Thus you would skip adjusting draw order during constant draw order frames in any animation.
Keydus having multiple slots of the same thing but placed at different spots in the hierarchy so I can choose to put my attachment between one or them
Basically yes. Just the wording "so I can choose to put my attachment between one or [of] them" is not quite what I meant. I meant that you can author these as multiple slots with placeholder attachments (e.g. multiple slots and placeholder attachments for trouser parts), which provides more than just a single insert-slot as an insertion point. But if you meant that, then yes.
Keydus adjust the DrawOrder at every frame which might become a performance hole at time
Basically yes, but see above for performance.