I’m trying to control a font material in RichTextBlock that uses StyleSet. Here is what I’m trying to do (simplified, not checking validity and so on):
UDataTable* StyleSet = TextToPrint2->GetTextStyleSet();
FName RowName = TEXT("danger_small");
FRichTextStyleRow* FontWithAStyle = StyleSet->FindRow<FRichTextStyleRow>(RowName, TEXT(""));
FTextBlockStyle TextStyle = FontWithAStyle->TextStyle;
UMaterialInterface* FontMaterial = Cast<UMaterialInterface>(TextStyle.Font.FontMaterial);
UMaterialInstanceDynamic* DynamicMaterialInstance = MaterialInstanceDynamic::Create(FontMaterial, TextToPrint2);
DynamicMaterialInstance->SetScalarParameterValue(FName("Speed"), 50.0);
I can see that dynamic material instance is created and parameter is changed there, but it doesn’t work since StyleSet is a copy, not reference I guess, so that dynamic instance is just a new thing that doesn’t have link to actual font applied to text block.
I was checking some setters in RichTextBlock but didn’t find a way to get dynamic material, could someone help me with that?