Delegates allow for event-driven programming and communication between classes. This tutorial provides a brief overview of delegates in C++ and Blueprints, covering the different types of delegate macros and their uses. Readers will learn how to declare, bind to, and broadcast delegates in C++ and Blueprints, as well as how to choose the appropriate delegate macro for their specific use case.
https://dev.epicgames.com/community/learning/tutorials/6xrK/unreal-engine-brief-overview-of-delegates-and-their-uses-in-c-and-blueprints
I received one thumbs up and one thumbs down already - thank you for viewing the tutorial and I hope I could help out! I’d like to highlight if anyone has feedback on this topic or notices that I’ve messed up a technical detail or two by trying to keep it as simple as possible, let me know!
Heyo, a small correction is needed.
You state that multicast delegates invoke functions in the order they are registered which is incorrect (at least in the version I checked.) I believe there’s also no assurances that the execution order won’t change in the future. It can only be assumed that the function will be called eventually.
void Broadcast(ParamTypes... Params) const
{
...
{
const InvocationListType& LocalInvocationList = Super::GetInvocationList();
// call bound functions in reverse order, so we ignore any instances that may be added by callees
for (int32 InvocationListIndex = LocalInvocationList.Num() - 1; InvocationListIndex >= 0; --InvocationListIndex)
{
...
}
}
...
}
Hey, thanks for catching that!
You’re right about the multicast delegate behaviour. I must’ve overlooked that detail about them invoking functions in the reverse order of registration.
I’ll be making edits to the tutorial to clear up that misconception. And yep, I’ll also add a little heads-up about not relying too heavily on a specific order of execution.
Thanks a bunch for pointing it out. If you spot anything else or just have some tips, always feel free to drop a line.