Event monitoring and notification in C++

需要引入的头文件为:#include \"System/GlobalEventSystem.h\"

The header files that need to be introduced are:#include "System/GlobalEventSystem.h"

1. Event Listen Bind: LISTEN_EVENT( EventTagOrId, Listener, EventName )

EventTagOrId:The Tag or ID of the event.
For Tag this is an EventTag type, you can use it both in Blueprint or C++.
As for Id, this is an FName type, which you can only use in C++.
Listener:The object of this event.
EventName:The name of the function that listens for this event. Example of use:
Tag definition:
Listen Event Tags
function:

2. Event Notification:

NOTIFY_EVENT( EventTagOrId, Listener, … )
NOTIFY_EVENT_BY_SENDER( EventTagOrId, Sender, Listener, … )
EventTagOrId:The Tag or ID of the event.
For Tag this is an EventTag type, you can use it both in Blueprint or C++.
As for Id, this is an FName type, which you can only use in C++.
Sender:
对于NOTIFY_EVENT,The default notifier is this.
对于NOTIFY_EVENT_BY_SENDER,The object that needs to be passed in to notify this message.
Listener:The target object to be notified.
… :For parameter list
For EventTagOrId is EventTag, it is the parameter list of EventTag.
For EventTagOrId, which is an ID of type FName, it is the parameter list of your C++ function.
NOTIFY_ALL_EVENT( EventTagOrId, … )
NOTIFY_ALL_EVENT_BY_SENDER( EventTagOrId, Sender, … ) This is similar to the two macros above, the only difference is that there is no Listener, which means that all bound listener events will be notified.

3. Cancel event listener binding

UNLISTEN_EVENT_OBJECT ( Object )
The object passed in is the object that cancels the event monitoring, which will unregister all events monitored by this object.
UNLISTEN_EVENT_OBJECTEVENT ( Object, EventTagOrId )
The object passed in is the object to cancel the event listening, and the event Tag or ID you need to unregister.

Comments

Table of Contents