void AActor::PreEditChange(UProperty* PropertyThatWillChange) { Super::PreEditChange(PropertyThatWillChange); if ( ReregisterComponentsWhenModified() ) { UnregisterAllComponents(); } }
void AActor::PreEditChange(UProperty* PropertyThatWillChange) { Super::PreEditChange(PropertyThatWillChange); UObjectProperty* ObjProp = Cast<UObjectProperty>(PropertyThatWillChange); UBlueprintGeneratedClass* BPGC = Cast<UBlueprintGeneratedClass>(GetClass()); if ( BPGC != nullptr && ObjProp != nullptr ) { BPGC->UnbindDynamicDelegatesForProperty(this, ObjProp); } if ( ReregisterComponentsWhenModified() ) { UnregisterAllComponents(); } }
void AActor::PreEditChange(UProperty* PropertyThatWillChange) { Super::PreEditChange(PropertyThatWillChange); UObjectProperty* ObjProp = Cast<UObjectProperty>(PropertyThatWillChange); UBlueprintGeneratedClass* BPGC = Cast<UBlueprintGeneratedClass>(GetClass()); if ( BPGC != nullptr && ObjProp != nullptr ) { BPGC->UnbindDynamicDelegatesForProperty(this, ObjProp); } // During SIE, allow components to be unregistered here, and then reregistered and reconstructed in PostEditChangeProperty. if ((GEditor && GEditor->bIsSimulatingInEditor) || ReregisterComponentsWhenModified()) { UnregisterAllComponents(); } }
void AActor::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { UProperty* PropertyThatChanged = PropertyChangedEvent.Property; FName PropertyName = PropertyThatChanged != NULL ? PropertyThatChanged->GetFName() : NAME_None; const bool bTransformationChanged = (PropertyName == Name_RelativeLocation || PropertyName == Name_RelativeRotation || PropertyName == Name_RelativeScale3D); // During SIE, allow components to reregistered and reconstructed in PostEditChangeProperty. // This is essential as construction is deferred during spawning / duplication when in SIE. if ((GEditor && GEditor->bIsSimulatingInEditor) || ReregisterComponentsWhenModified()) { // In the Undo case we have an annotation storing information about constructed components and we do not want // to improperly apply out of date changes so we need to skip registration of all blueprint created components // and defer instance components attached to them until after rerun if (CurrentTransactionAnnotation.IsValid()) { UnregisterAllComponents(); TInlineComponentArray<UActorComponent*> Components; GetComponents(Components); Components.Sort([](UActorComponent& A, UActorComponent& B) { if (&B == B.GetOwner()->GetRootComponent()) { return false; } if (USceneComponent* ASC = Cast<USceneComponent>(&A)) { if (ASC->GetAttachParent() == &B) { return false; } } return true; }); bool bRequiresReregister = false; for (UActorComponent* Component : Components) { if (Component->CreationMethod == EComponentCreationMethod::Native) { Component->RegisterComponent(); } else if (Component->CreationMethod == EComponentCreationMethod::Instance) { USceneComponent* SC = Cast<USceneComponent>(Component); if (SC == nullptr || SC == RootComponent || (SC->GetAttachParent() && SC->GetAttachParent()->IsRegistered())) { Component->RegisterComponent(); } else { bRequiresReregister = true; } } else { bRequiresReregister = true; } } RerunConstructionScripts(); if (bRequiresReregister) { ReregisterAllComponents(); } } else { UnregisterAllComponents(); RerunConstructionScripts(); ReregisterAllComponents(); } } // Let other systems know that an actor was moved if (bTransformationChanged) { GEngine->BroadcastOnActorMoved( this ); } if (GetWorld()) { GetWorld()->bDoDelayedUpdateCullDistanceVolumes = true; } FEditorSupportDelegates::UpdateUI.Broadcast(); Super::PostEditChangeProperty(PropertyChangedEvent); }