#unreal

All Delegate types require the bound function to match the delegate’s signature. If you don’t know what the function’s signature is, check the delegate declaration from its header file.

Below examples show usage with multicast delegates. Singlecast delegates work the same way, but the functions are called BindSomething instead of AddSomething.

A note on editors

If you are using an editor that doesn’t properly support Unreal’s macros, you might not get the correct autocompletion when adding delegates. AddDynamic in particular is problematic.

See: Setting up editors for Unreal development

Dynamic delegates

For dynamic delegates, the object you’re binding to must be an UObject.

//Typical usage to bind to a function in the current class:
MyDelegate.AddDynamic(this, &ThisClass::FunctionName);

Non-dynamic delegates

Non-dynamic delegates can bind to objects that aren’t UObjects, but the most common use is binding to an UObject via AddUObject

//Typical usage to bind to a function in the current class:
MyDelegate.AddUObject(this, &ThisClass::FunctionName);

These can also bind to lambdas which can be convenient:

MyDelegate.AddLambda([](DelegateParam* Foo) {
	//do something
});

How to tell if a delegate is dynamic or not

Other than IDE code-assist, there’s no other way to tell besides looking at how the delegate is declared. If it uses one of the DECLARE_DYNAMIC... macros, it’s a dynamic delegate.