Hello,
I am currently trying to change the default value of a material parameter collection from an editor button.
I made a lot of try, commenting/uncommenting some lines, but I did not find a way to make it work.
// Update the asset
// scalarParameter.DefaultValue = (scalarParameter.DefaultValue > 0.5f) ? 0.0f : 1.0f;
// mpc->PostEditChange();
//mpc->MarkPackageDirty();
//package->MarkPackageDirty();
//UPackage::SavePackage(package, nullptr, EObjectFlags::RF_Public, *PackagePath.ToString());
// Update the world parameter collection instance
UWorld* world = GEditor->GetEditorWorldContext().World();
if (world != nullptr)
{
UKismetMaterialLibrary::SetScalarParameterValue(world, mpc, ParameterName, (scalarParameter.DefaultValue > 0.5f) ? 0.0f : 1.0f);
// world->UpdateParameterCollectionInstances(true);
//UMaterialParameterCollectionInstance* mpci = world->GetParameterCollectionInstance(mpc);
//mpci->PostEditChange();
}
Whenever theses lines are called, it seems to break a link between the Material Parameter Collection asset, and the one used in the level. After the call, changing the value in the Material Parameter Collection manually does not work anymore (I have to reload the level).
Any clue ?