Description

Currently value propagation is handled at the property node level (c.f., PropagateContainerPropertyChange), and is unavailable to any other editor code / scripting (whether in Python or BP or C++). There's a frequent desire to manipulate the archetype of things like Blueprints when doing editor scripting or enterprise import-ey things, and right now if you have existing instances there's no good way to get them updated and you run into weird/buggy situations where if you save an open map after making an edit like this, you actually end up with a worse outcome than if you didn't save the map.

Steps to Reproduce

Create a Blueprint with an integer property and place three instances in a level.

Update the value on two of the instances to be non-default (e.g., 1 and 2)

Run something like this code on the class default object:

USTRUCT()
struct FSourceDummy
{
	GENERATED_BODY()

	UPROPERTY()
	int32 SourceValue;
};


void UQAKismetHelperLibrary2::SetPropertyMagic(TSubclassOf<UObject> ClassPtr, FName PropertyName, int32 PropertyValue)
{
	const FProperty* TargetProp = PropertyAccessUtil::FindPropertyByName(PropertyName, ClassPtr);
	const FProperty* SourceProp = PropertyAccessUtil::FindPropertyByName(GET_MEMBER_NAME_CHECKED(FSourceDummy, SourceValue), FSourceDummy::StaticStruct());

	FSourceDummy Dummy;
	Dummy.SourceValue = PropertyValue;

	const EPropertyAccessResultFlags AccessResult =
		PropertyAccessUtil::SetPropertyValue_Object(TargetProp, ClassPtr->GetDefaultObject(), SourceProp, SourceProp->ContainerPtrToValuePtr<void>(&Dummy), INDEX_NONE, PropertyAccessUtil::EditorReadOnlyFlags, EPropertyAccessChangeNotifyMode::Default);

	UE_LOG(LogInit, Warning, TEXT("%d"), AccessResult);
}

Expected:

The instance with an unmodified value will now read the changed value, same as if you edited the default value on the BP in a property editor.

Actual:

The first instance is unchanged and still reads 0, but if the map is reloaded without being saved, it will change to the new value as expected.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-93193 in the post.

0
Login to Vote

Won't Fix
CreatedMay 14, 2020
ResolvedJul 19, 2022
UpdatedJan 22, 2024