Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
by John P. Doran, William Sherif, Stephen Whittle
How it works...
As you might expect, the delegate type needs to be explicitly declared as a multicast delegate rather than a standard single-binding one. Our new Listener class is very similar to our original DelegateListener. The primary difference is that we need to store a reference to our delegate instance in FDelegateHandle.
When the actor is destroyed, we safely remove ourselves from the list of functions that are bound to the delegate by using the stored FDelegateHandle as a parameter to Remove().
The Broadcast() function is the multicast equivalent of ExecuteIfBound(). Unlike standard delegates, there is no need to check whether the delegate bound either in advance or with a call such as ExecuteIfBound. Broadcast() is safe to run, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access