It's always best to simplify the project for us. Delete everything, like this:
http://n4te.com/x/1413-test-2-hats.zip
Then when providing the project, tell us 1) how to reproduce the problem, 2) what happens, and 3) what you expected to happen.
In that project the girl skin is active. 2 hats appear. The hat under the boy-test
bone should not appear because that bone is under the boy skin, which is not visible.
If you export (add an empty animation first) and look in Skeleton Viewer, only one hat appears. That is correct, the editor is wrong.
Actually SV shows some debug lines for the second hat, which is wrong. We'll fix that.
Both hats are weighted to the girl-test
bone. Due to that the boy-test
bone transform doesn't actually affect the attachment. That allows it to be rendered, otherwise the invalid bone transform would render all the vertices at 0,0 and you'd not see the image. The editor shouldn't be rendering it in any case. We'll fix that.
You mentioned that at runtime sometimes it gets rendered. That shouldn't be possible, eg in spine-libgdx:
EsotericSoftware/spine-runtimesblob/4.2/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java#L247-L249
If the slot's bone is not active, the slot's attachment is not rendered. If you do see an attachment getting rendered at runtime when it shouldn't, please report it. It could be that some runtimes don't have this check.
The bone transform values for inactive bones are cleared in the editor, so the attachment vertices are always nuked to 0,0. At runtime that work isn't done for efficiency, because those attachments should never be rendered anyway. That means you may only see the attachment being rendered incorrectly after the skin bone has been active, then made inactive.
In the editor, a bone is inactive when it's in a skin but the skin isn't visible. At runtime it's a little different. The skeleton has a single skin (and a default skin, but ignore that for skin bones) and the skin has a list of bones. A bone is inactive if it is in one or more skins (its data.skinRequired
is true) and it is not in the skin's list of bones.
If someone modifies the skeleton's skin (by adding/removing attachments or bones or constraints) or if bones, constraints, or weighted path attachments are added or removed then Skeleton updateCache
must be called:
http://esotericsoftware.com/spine-api-reference#Skeleton-updateCache
If someone sets a skin on a skeleton then modifies the skin (something that changes the skin bones, like adding another skin to it), it could result in a bone being active when it should not be. Note updateCache
is called for you if you call setSkin
and that changes the skin.