Hello,
I need to programmatically assign default values to a blueprint’s parameters in the editor via c++ (at editor time).
The idea is to change the default values, recompile the blueprint and then all instances of it will automatically update to the new values.
I have the code below, it runs, but the default value doesn’t change in the editor. If I read back the set value it is correct.
void UEditBlueprint::TestSetPropertyDefault(UBlueprint* aBlueprint)
{
UBoolProperty* boolProp = Cast<UBoolProperty>(aBlueprint->GeneratedClass->FindPropertyByName(FName(TEXT("SetPropertyTestBool"))));
boolProp->SetPropertyValue_InContainer(aBlueprint, true);
// Test read back
bool propVal = boolProp->GetPropertyValue_InContainer((UObject*)(aBlueprint));
aBlueprint->MarkPackageDirty();
FKismetEditorUtilities::CompileBlueprint(aBlueprint);
}
It is needed for an automation pipeline, so ideally I want to solve it like this, not with setting values of every reference in every level. This example is for a bool, the actual parameter will be an array of actors which are created programmatically.
I have tried many different approaches and am out of ideas. I think I might be working on a wrong reference or perhaps missing a call which propagates the change (to the UI)?