Hi!
I want others to subscribe to an event threw an interface, how to?
For example:
Interface IKillable:
has event:
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FEOnDeath, AActor*, actor, AActor*, killer);
and we could access this event via:
#1
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
void EventOnDeath_Sub(Actor* subscriber, XXX funName, bool subOrDesub);
or #2
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
FEOnDeath GetDeathEvent();
#2 Unreal doesnt recognize the signature and seems impossible.
#1 is the real question: how do I pass a function to it?
ie.: the Class implementing the interface and function would do:
void EventOnDeath_Sub(Actor* subscriber, XXX funName, bool subOrDesub){
EventOnDeath.AddDynamic(subscriber, XXX);
//the function signature is void XXX(UObject*, Actor*,Actor*)
}
and the using class would do:
IKillable->EventOnDeath_Sub(this, &MyClass::DoOnDeath, true);
I hope Im making sense,
Thanks