If I delete the line setting the param, it doesn’t crash but then nothing happens, so that’s definitely no solution.
Okay, so something’s not initialized. That’s what I wanted to catch with the if(materialDynamic != nullptr).
I’m loading the material via the FObjectFinder and setting it via this->SetMaterial(); This works since the material actually is on my mesh. So the material has to be initialized.
Maybe when creating a dynamic instance.
materialDynamic is a attribute of my component class.
I tried something different with the constructor. Now it looks like this but I still get the same result:
auto materialAsset = ConstructorHelpers::FObjectFinder<UMaterialInstance>(TEXT("MaterialInstace'/Game/Materials/MI_Editor_Node.MI_Editor_Node'"));
if (materialAsset.Object != nullptr)
{
UMaterialInstance * mInstance = Cast<UMaterialInstance>(materialAsset.Object);
if (mInstance != nullptr)
{
materialDynamic = UMaterialInstanceDynamic::Create(mInstance, this, FName("Material"));
//materialDynamic = CreateAndSetMaterialInstanceDynamicFromMaterial(0, GetMaterial(0));
SetMaterial(0, materialDynamic);
}
else
{
Logging::Log("Couldn't cast material to instance");
}
}
else
{
Logging::Log("Could not find Asset at path '/Game/Materials/MI_Editor_Node.MI_Editor_Node' in CellEditor_NodeComponent.Constructor");
}