E4-Unreal / test-simple-game-framework

simpleFramework for UE 5.1.0
MIT License
0 stars 1 forks source link

이벤트 디스패처에 이벤트 바인딩 (Delegate) #30

Open Eu4ng opened 1 year ago

Eu4ng commented 1 year ago

Delegate에 등록할 함수는 UFUNCTION()메크로를 붙여야 합니다.

Delegate 선언

// MyComponent.h
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDelegate);

UCLASS()
class MYGAME_API UMyComponent : public UActorComponent
{
    GENERATED_BODY()

    ...
    UPROPERTY(BlueprintAssignable)
    FDelegate OnUpdate;
    ...
}

// MyComponent.cpp

...
if(OnUpdate.IsBound())
{
    OnUpdate.Broadcast();
}
...

// MyActor.cpp

...
MyComponent->OnUpdate.AddDynamic(this, &AMyActor::Action);
...

참고 링크