just in case, I had side effect in non editor version in 4.7 with dynamic material. The material was dropped about 30sec after the first usage (surely garbagged). So test that in standalone game before moving to far with this code ^^
I didn’t find a solution for my issue, I try to talk on it on answerhub without solution as of now. So I move this part in UMG and that solve my problem.
Elvince, you could use the AddToRoot method to prevent the material being garbage out.
auto ConstInst = Cast<UMaterialInstanceConstant>(
auto DynamicInst = UMaterialInstanceDynamic::Create(ConstInst, nullptr);
DynamicInst->AddToRoot(); // Prevent the dynamic material being GC
At least, UE5 has this option. I didn’t test this in prev versions.
I hope, this will help anyone