I’ve been trying to implement PostEditChangeProperty with some success but there are still some areas that are not clear for me. Especially FMultiComponentReregisterContext. Consider this API example AActor::PostEditChangeProperty | Unreal Engine 5.2 Documentation
#if WITH_EDITOR
void AMyComponentSpawner::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
//Get all of our components
TArray<UActorComponent*> OwnedComponents;
GetComponents(OwnedComponents);
//Get the name of the property that was changed
FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
// We test using GET_MEMBER_NAME_CHECKED so that if someone changes the property name
// in the future this will fail to compile and we can update it.
if ((PropertyName == GET_MEMBER_NAME_CHECKED(AMyComponentSpawner, MyMesh)))
{
** FMultiComponentReregisterContext ReregisterContext(OwnedComponents); **
for (UActorComponent* Comp : OwnedComponents)
{
if (UStaticMeshComponent* MeshComp = Cast<UStaticMeshComponent>(Comp))
{
MeshComp->StaticMesh = MyMesh; // Update the component to the new mesh
}
}
}
// Call the base class version
Super::PostEditChangeProperty(PropertyChangedEvent);
}
#endif
According to this link: FMultiComponentReregisterContext | Unreal Engine 5.2 Documentation , FMultiComponentReregisterContext does this:
It explains me nothing. What ReregisterContext does? Why PostEditChangeProperty code example is using it?