Nice! Looking into it, thanks for the heads up.
15 Mars 2016, 15:25
Based on your example, I've made a fillSlot function that works well, it makes my shield flashes just as intended which is great. Problem is, fillSlot has no effect after I call fillSkeleton, which is the function I use to make the whole animation flash. So basically, once my character gets hit, his shield won't flash anymore when he blocks.
I ensured that the CustomSlotMaterials was still present and not overwritten so I'm not sure at all why this happen. Am I using the system all wrong or is this is an unintended behavior? Here are both functions:
public void fillSlot (string pSlotName, Color pColor, float pPower, float pDuration, Material pMaterial) {
Slot slot = skelAnima.skeleton.FindSlot(pSlotName);
// Add the material if no material assigned to that slot
if (!skelAnima.CustomSlotMaterials.ContainsKey(slot)) {
skelAnima.CustomSlotMaterials[slot] = pMaterial;
}
Material material = skelAnima.CustomSlotMaterials[slot];
material.SetFloat("_FillPhase", 0);
material.SetColor("_FillColor", pColor);
DOTween.To(() => material.GetFloat("_FillPhase"), x => material.SetFloat("_FillPhase", x), pPower, pDuration).From();
}
(fillSkeleton works well no matter what)
public void fillSkeleton (Color pColor, float pPower, float pDuration) {
materialBlock.SetFloat("_FillPhase", 0);
materialBlock.SetColor("_FillColor", pColor);
DOTween.To(() => materialBlock.GetFloat("_FillPhase"), x => materialBlock.SetFloat("_FillPhase", x), pPower, pDuration).From().OnUpdate(flashUpdate);
}
NB: regarding Materials :
- fillSkeleton uses the origin Material with SkeletonFillable shader.
- fillSlot uses a copy of this Material. (that seemed like the only way to display the shield texture properly)