UE19.2 - SetMaterial to ProceduralMesh - cant fix it.

Hi there,

i try to get my procedural Mesh working but currently i cant get my Material Set. I Got it in UE18.3 - so what changed?

i followed the Example here:

and added in Header:

UPROPERTY(EditAnywhere, Category = "Materials")
        UMaterial* My_Material_Variable;

added in Implementation

mesh->CreateMeshSection_LinearColor(0, vertices, Triangles, normals, UV0, vertexColors, tangents, true);

    // Enable collision data
mesh->SetMaterial(0, My_Material_Variable);

i know that it wanted to have a MaterialInstance - but this does not change anything (both do not work :smiley: ).
Also what happened to Material.Object - seems it isnt anymore?

The header Variable works just fine and as expected, but it is not assigning the Material to Element0

i tried to put it in BeginPlay - but it crashes there. In the constructor it isnt assigning the Material.

How can i get it working? have i forgotten an include?`(but there are no compiler errors)

thanks - Johannes

Thanks for “having a look” the answer is:

in header:

UPROPERTY(EditAnywhere) UMaterialInterface* Material;

and in Implementation:

UMaterialInstanceDynamic* DynMaterial = UMaterialInstanceDynamic::Create(Material, mesh);
//set paramater with Set***ParamaterValue
DynMaterial->SetScalarParameterValue("MyParameter", 1.0);
mesh->SetMaterial(0, DynMaterial);