This plug-in was last built against Windows, Unreal Engine 5.4+.
However, this code should work on other Unreal Engine versions.
You can install from the release section.
Alternatively, you can install this plugin via terminal with git.
Here is the command for installing it:
git clone [email protected]:MrRobinOfficial/Unreal-EventBus.git EventBus
This plugin features a subsystem named UEventSubsystem
, which enables you to register and invoke events. The event subsystem maintains a dictionary of events and their corresponding callbacks. These callbacks are stored in a list, allowing multiple callbacks to be registered for the same event. This design promotes a modular and maintainable approach to event-based systems.
The subsystem supports two types of invocation: UEventSubsystem::Invoke()
and UEventSubsystem::InvokeWithPayload()
. The payload is a UObject
pointer that can be used to pass data between callbacks.
Inside that class, there a couple of functions that you can use.
#include "EventSubsystem.h"
UGameInstance* GameInstance = ...;
auto* EventSubsystem = GameInstance->GetSubsystem<UEventSubsystem>();
UEventSubsystem* EventSubsystem = ...;
FOnEventSignature Delegate;
Delegate.BindUObject(this, &UEventSubsystem::OnPlayerDied);
EventSubsystem->RegisterEvent(TEXT("player_died"), Delegate);
// Callback will be invoked when `player_died` event is invoked
UFUNCTION()
void OnPlayerDied(UObject* Payload) { }
UEventSubsystem* EventSubsystem = ...;
FOnEventSignature Delegate;
Delegate.BindUObject(this, &UEventSubsystem::OnPlayerDied);
EventSubsystem->UnregisterEvent(TEXT("player_died"), Delegate);
// Callback will be invoked when `player_died` event is invoked
UFUNCTION()
void OnPlayerDied(UObject* Payload) { }
UEventSubsystem* EventSubsystem = ...;
EventSubsystem->UnregisterAllEvents(TEXT("player_died"));
UObject* Payload = ...;
EventSubsystem->InvokeWithPayload(TEXT("player_died"), Payload);
EventSubsystem->InvokeWithPayload(TEXT("player_died"));
If you have any questions or issue, just write either to my YouTube channel, Email or Twitter DM.