void UActorComponent::DestroyComponent() { // First, unregister if registered if(IsRegistered()) { UnregisterComponent(); } // Then remove from Components array, if we have an Actor AActor* Owner = GetOwner(); if(Owner != NULL) { Owner->SerializedComponents.Remove(this); if (Owner->GetRootComponent() == this) { Owner->SetRootComponent(NULL); } } // Tell the component it is being destroyed OnComponentDestroyed(); // Finally mark pending kill, to NULL out any other refs MarkPendingKill(); }
void UActorComponent::BeginDestroy() { if (bHasBegunPlay) { EndPlay(EEndPlayReason::Destroyed); } // Ensure that we call UninitializeComponent before we destroy this component if (bHasBeenInitialized) { UninitializeComponent(); } ExecuteUnregisterEvents(); // Ensure that we call OnComponentDestroyed before we destroy this component if (bHasBeenCreated) { OnComponentDestroyed(); } World = NULL; // Remove from the parent's OwnedComponents list if (AActor* MyOwner = GetOwner()) { MyOwner->RemoveOwnedComponent(this); } Super::BeginDestroy(); }
void UActorComponent::DestroyComponent(bool bPromoteChildren/*= false*/) { // Avoid re-entrancy if (bIsBeingDestroyed) { return; } bIsBeingDestroyed = true; if (bHasBegunPlay) { EndPlay(EEndPlayReason::Destroyed); } // Ensure that we call UninitializeComponent before we destroy this component if (bHasBeenInitialized) { UninitializeComponent(); } // Unregister if registered if(IsRegistered()) { UnregisterComponent(); } // Then remove from Components array, if we have an Actor if(AActor* MyOwner = GetOwner()) { if (IsCreatedByConstructionScript()) { MyOwner->BlueprintCreatedComponents.Remove(this); } else { MyOwner->RemoveInstanceComponent(this); } MyOwner->RemoveOwnedComponent(this); if (MyOwner->GetRootComponent() == this) { MyOwner->SetRootComponent(NULL); } } // Tell the component it is being destroyed OnComponentDestroyed(); // Finally mark pending kill, to NULL out any other refs MarkPendingKill(); }
void UActorComponent::BeginDestroy() { // Ensure that we call OnComponentDestroyed before we destroy this component if(bHasBeenCreated) { #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) //UE_LOG(LogActor, Warning, TEXT("UChildActorComponent::BeginDestroy called on '%s' before without OnComponentDestroyed being called."), *this->GetPathName()); #endif OnComponentDestroyed(); } ExecuteUnregisterEvents(); World = NULL; Super::BeginDestroy(); }