DragonBones / DragonBonesCSharp

DragonBones C# Runtime
MIT License
533 stars 198 forks source link

Set Color Bug ? #39

Closed zzzxxccvv closed 6 years ago

zzzxxccvv commented 6 years ago

I want change the color of the armature like this

UnityDragonBonesData dragonBoneData = (UnityDragonBonesData)Instantiate(Resources.Load("xxx_Data"));
UnityFactory.factory.LoadData(dragonBoneData);
body = UnityFactory.factory.BuildArmatureComponent("armatureName");

for (int i = 0; i < body.sortedSlots.Count; i++)
{
      body.sortedSlots[i].skinSlotData.slot.color.alphaMultiplier = 0.1f;
}

But it does not work immediately, just have effect on the next time creating the Armature in the Unity Editor.

I guess it calls the wrong api some where for Editor or I used in a wrong way :(

akdcl commented 6 years ago

Hi, dragonBones runtime can not support set color by dragonBones api yet. You could modify color by unity api.

var unityDisplay = slot.display;
...
//set unityDisplay color by unity api
zzzxxccvv commented 6 years ago

Thanks.

var display = body.armature.GetSlot("hunter_hat1_png").display;
GameObject go = (GameObject)display;
MeshRenderer re = go.GetComponent<MeshRenderer>();
re.material.color = Color.red;

It works