Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
by John P. Doran, William Sherif, Stephen Whittle
How it works...
This recipe combines both of the previous recipes in this chapter so far. We override EndPlay, which is an event that's implemented as a virtual function, so that we can execute code when our DelegateListener leaves play.
In that overridden implementation, we call the Unbind() method on the delegate, which unlinks the member function from the DelegateListener instance.
Without this being done, the delegate dangles like a pointer, leaving it in an invalid state when the DelegateListener leaves the game. Using BindUObject() helps avoid most of these situations, and just a few unfortunate timing situations could cause calls on objects to be marked for destruction. It is still a good practice to unbind delegates manually, even ...
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