Changing the name of a function that is bound to a delegate, or attempting to bind a delegate to a second function, causes the new/changed function to not be called when the delegate is triggered.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Test)
UBoxComponent* TestBox;
UFUNCTION(BlueprintCallable, Category = Test)
void OriginalFunction(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
TestBox = CreateDefaultSubobject<UBoxComponent>(TEXT("TestBox")); RootComponent = TestBox; TestBox->OnComponentBeginOverlap.AddDynamic(this, &AMyActor::OriginalFunction);
void AMyActor::OriginalFunction(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult) { if (GEngine) { GEngine->AddOnScreenDebugMessage(-1, 4.f, FColor::Magenta, TEXT("OriginalFunction")); } }
Result:
When walking into the box after changing the function name, the debug message does not appear
Expected:
Delegate is still able to recognize the bound function after changing the function name
Head over to the existing Questions & Answers thread and let us know what's up.
28 |
Component | UE - Foundation - Core |
---|---|
Affects Versions | 4.13.2, 4.14 |
Created | Nov 9, 2016 |
---|---|
Resolved | Jun 16, 2017 |
Updated | Jul 14, 2021 |