The SpineSkeletonRender Component seems can not change material parameter due to design (I assume).
According to this, in UE4, if you want to modify parameters in runtime, you have to create MIDs in BP, then assign to materials.
But all of the materials for the Render Component are ready only.
Even if I've changed to BlueprintReadWrite it still won't work because it seems that it will create MIDs in every ticks.
So it is not possible to change parameters in runtime thus changing color is impossible.
If I was right on this, then I want to request either a MIDs compatible Render Component or a color changing feature.
If I was wrong, please tell me how to use MIDs with SpineSkeletonRender Component.
The only way I can think of is that use spine to create a new animation, change slot colors and then play it on the other track.
Thank you!
Update, so here is the workaround.
Add these line in SpineSkeletonRendererComponent.h
UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
FLinearColor VectorParameter;
UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
FName VectorParameterName;
Then initialize these variables in constructor of SpineSkeletonRendererComponent.cpp
VectorParameterName = FName(TEXT("TintColor"));
VectorParameter = FLinearColor(1.0f, 1.0f, 1.0f);
Now find all the MIDs created in Tick Component, add this line below every SetTextureParameterValue.
material->SetVectorParameterValue(VectorParameterName, VectorParameter);
Finally, add these lines below UpdateMesh(skeleton->GetSkeleton()); inside TickComponent so it can update parameters every frame.
for (int i = 0; i < skeleton->Atlas->atlasPages.Num(); i++)
{
atlasScreenBlendMaterials[i]->SetVectorParameterValue(VectorParameterName, VectorParameter);
atlasNormalBlendMaterials[i]->SetVectorParameterValue(VectorParameterName, VectorParameter);
atlasAdditiveBlendMaterials[i]->SetVectorParameterValue(VectorParameterName, VectorParameter);
atlasMultiplyBlendMaterials[i]->SetVectorParameterValue(VectorParameterName, VectorParameter);
}
Then it'll work.
I've attached both .h and .cpp file in case someone else encountered this problem.
Documents.zip
Here is my BP setup:
And the video:
12.zip