void AActor::PreEditChange(UProperty* PropertyThatWillChange) { Super::PreEditChange(PropertyThatWillChange); if ( ReregisterComponentsWhenModified() ) { UnregisterAllComponents(); } }
void AActor::PostEditMove(bool bFinished) { if ( ReregisterComponentsWhenModified() ) { UBlueprint* Blueprint = Cast<UBlueprint>(GetClass()->ClassGeneratedBy); if(Blueprint && (Blueprint->bRunConstructionScriptOnDrag || bFinished) && !FLevelUtils::IsMovingLevel() ) { FNavigationLockContext NavLock(GetWorld(), ENavigationLockReason::AllowUnregister); RerunConstructionScripts(); } } if ( bFinished ) { GetWorld()->bDoDelayedUpdateCullDistanceVolumes = true; GetWorld()->bAreConstraintsDirty = true; FEditorSupportDelegates::RefreshPropertyWindows.Broadcast(); // Let other systems know that an actor was moved GEngine->BroadcastOnActorMoved( this ); FEditorSupportDelegates::UpdateUI.Broadcast(); } // If the root component was not just recreated by the construction script - call PostEditComponentMove on it if(RootComponent != NULL && !RootComponent->IsCreatedByConstructionScript()) { // @TODO Should we call on ALL components? RootComponent->PostEditComponentMove(bFinished); } if (bFinished) { // update actor and all its components in navigation system after finishing move // USceneComponent::UpdateNavigationData works only in game world UNavigationSystem::UpdateNavOctreeBounds(this); TArray<AActor*> ParentedActors; GetAttachedActors(ParentedActors); for (int32 Idx = 0; Idx < ParentedActors.Num(); Idx++) { UNavigationSystem::UpdateNavOctreeBounds(ParentedActors[Idx]); } // not doing manual update of all attached actors since UpdateActorAndComponentsInNavOctree should take care of it UNavigationSystem::UpdateActorAndComponentsInNavOctree(*this); } }
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); }