In some my animations i need to change draw order by keyframes. So i need to reset draw order for another animations, on transition. How can i achieve that? I have found way to reset the whole skeleton here (http://esotericsoftware.com/spine-using-runtimes/#Animation-changes) by calling setToSetupPose, setBonesToSetupPose, or setSlotsToSetupPose. But it resets too much, i just need to reset draw order. Is there any better solution, but adding draw order keyframe in begin of all animations?
Reset draw order
- Изменено
Just open Skeleton.cs
And add the method that only resets draw order:
public void SetDrawOrderToSetupPose () {
ExposedList<Slot> slots = this.slots;
drawOrder.Clear();
for (int i = 0, n = slots.Count; i < n; i++)
drawOrder.Add(slots.Items[i]);
}
It's basically SetSlotsToSetupPose but without the slots resetting.
I'll run the idea by Nate when he gets back.
Pharan написал
Oh, that' great. Changing draw order for overlapping things is a really common task, i suppose it could be usefull not only for me. Thank you.
21 Mar 2016, 13:13
udp: I find extension method is more safe on the place, because I update spine-libs pretty oft.
public static void SetDrawOrderToSetupPose(this Skeleton skeleton) {
ExposedList<Slot> slots = skeleton.slots;
skeleton.drawOrder.Clear();
for (int i = 0, n = slots.Count; i < n; i++) {
skeleton.drawOrder.Add(slots.Items[i]);
}
}