Adding Create Dynamic Material Instance node and setter node to actor blueprint trough C++ ?

Hi @Putemonsteret, how are you? Hope you’re doing great!

From what I understand, you’re trying to create a node (from C++) where you pass a material as input, and then internally (in C++) the class creates a Dynamic Material Instance from that input material, and then stores it (for example in a TArray of Dynamic Material Instances), and later exposes that array to Blueprints (with the TArray marked as UProperty(EditAnywhere)) so that you can access and edit the material instances from Blueprint.

Is that correct? If that is what you want to achieve, you can store all the new dynamic material instances inside a exposed property, something like this:


// On the .h
UPROPERTY(BlueprintReadWrite)
TArray<UMaterialInstanceDynamic*> MID;

// On the .cpp
void AddDynamicMaterialInstanceNodesetupToActor(class UMaterialInterface* Parent, FName OptionalName, EMIDCreationFlags CreationFlags)
{
    if (UMaterialInstanceDynamic* NewDynamicMaterial = 
    UKismetMaterialLibrary::CreateDynamicMaterialInstance(this, Parent, OptionalName, CreationFlags))
{
    MID.Add(NewDynamicMaterial );
}
}