Let's say I have a class UFoo which has a dynamic delegate myDelegate with no parameters. I cannot modify the contents of UFoo in any way.
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FMyDelegate);
UCLASS()
class UFoo : public UObject
{
GENERATED_BODY()
public:
UPROPERTY()
FMyDelegate myDelegate;
// rest of class
}
I also have a class UBar which contains three UFoo-type objects foo1, foo2 and foo3. UBar also has a function DoStuff(int32 num) which takes a single integer as a parameter.
UCLASS()
class UBar : public UObject
{
GENERATED_BODY()
public:
UFUNCTION()
void DoStuff(int32 num);
UPROPERTY()
TObjectPtr<UFoo> foo1;
UPROPERTY()
TObjectPtr<UFoo> foo2;
UPROPERTY()
TObjectPtr<UFoo> foo3;
// rest of class
}
I would like to bind DoStuff to the myDelegate delegate of foo1, foo2 and foo3. But beacusebecause the list of parameters is different between the delegate and DoStuff, this obviously cannot be done as is.
That being said, I know that in the case of foo1's delegate, the integer value passed to DoStuff should always be 1. Likewise, it should be 2 for foo2, and 3 for foo3. In that case, does this become possible? Is there a way to specify a default parameter value of sorts for DoStuff that is different per UFoo instance, allowing me to bind DoStuff to their delegates despite the differing parameter lists?