Sorting order is on the MeshRenderer. Set meshRenderer.sortingOrder
. The reason why you don't see anything about it in SkeletonRenderer's code is that the inspector thing is just reflecting the hidden MeshRenderer values. But they're serialized by the MeshRenderer normally, so it persists in objects when you save.
There's a few other threads where people asked the same question. The code had a few gotchas but wasn't much longer than a few lines. I'll try to look for them.
26 Jan 2016 6:03 am
// May throw a harmless error because it couldn't detect an assigned skeletonDataAsset. Maybe not. I think that was fixed.
SkeletonAnimation skeletonAnimation = gameObject.AddComponent<SkeletonAnimation>();
skeletonAnimation.skeletonDataAsset = mySkeletonDataAsset;
skeletonAnimation.Reset(); // In the future, this will be renamed to "Initialize" or something because of current method name collisions.
// Now you can do whatever to it.
skeletonAnimation.state.SetAnimation(0, "walk", true);
26 Jan 2016 7:48 am
Just updated the runtime. If you update (or just update your SkeletonRenderer.cs and SkeletonAnimation.cs files from the git repo), you can do the above with this call to a static method:
var myNewSkeletonAnimation = SkeletonAnimation.AddToGameObject(gameObject, skeletonDataAsset);
We'll handle any future changes to the API as long as you do it that way.