I am wondering what is the proper way to change DisplayIndex of a slot via API. For instance, I have several hairstyles or hats for my character and would like to swap them on the fly via code. Intuitively I use
_hairstyleSlot.displayIndex = INDEX;
But this value will be overriden back to default when next frame of animation will be played because of
var displayIndex = _currentFrame.displayIndex;
if (_playState >= 0 && slot.displayIndex != displayIndex)
{
slot._setDisplayIndex(displayIndex);
}
in timeline slot _onArriveAtFrame();
As far as I've understood from sources, every slot's frame now has its display index set, even if it isn't specified in the DragonBones editor:
And even if slot is not animated, the default timeline will be created nevertheless, with one frame effectively setting displayIndex to default one.
So, the question is - am I missing something? What is the proper way to set DisplayIndex from my code so it wont be changed back to default value on next playback of animation
Kind regards,
Serj
P.S. if you interested, so far to resolve this in a quick and dirty manner I just patched source code by adding new slot bool property displayIndexIsControlledByApi so if it is raised, the animation code wont change displayIndex at all
Hello!
I am wondering what is the proper way to change DisplayIndex of a slot via API. For instance, I have several hairstyles or hats for my character and would like to swap them on the fly via code. Intuitively I use
But this value will be overriden back to default when next frame of animation will be played because of
in timeline slot _onArriveAtFrame();
As far as I've understood from sources, every slot's frame now has its display index set, even if it isn't specified in the DragonBones editor:
And even if slot is not animated, the default timeline will be created nevertheless, with one frame effectively setting displayIndex to default one.
So, the question is - am I missing something? What is the proper way to set DisplayIndex from my code so it wont be changed back to default value on next playback of animation
Kind regards, Serj
P.S. if you interested, so far to resolve this in a quick and dirty manner I just patched source code by adding new slot bool property displayIndexIsControlledByApi so if it is raised, the animation code wont change displayIndex at all