Closed jtarczykowski closed 3 years ago
Let's see, behind the curtain the function that calls it is
and that is handled by this class which has a static handler:
you have a bunch of overloaded emits here: https://github.com/getnamo/global-event-system-ue4/tree/be3836f3648c9fca7a19db116c52c2de8f525517/Source/GlobalEventSystem/Private/GESHandler.h#L52, the only one not relevant for c++ is probably the one param version which converts a uproperty pointer (https://github.com/getnamo/global-event-system-ue4/tree/be3836f3648c9fca7a19db116c52c2de8f525517/Source/GlobalEventSystem/Private/GESHandler.h#L59, don't use this one)
Only major problem in using this is that it is in the private folder, so to use it outside, the class would need to be moved out.
To summarize, you want to do something like
//assuming e.g. this struct you want to emit (and it can be blueprint accessible type too)
USTRUCT()
struct FTestCppStruct
{
GENERATED_BODY()
UPROPERTY()
int32 Index;
UPROPERTY()
float SomeNumber;
UPROPERTY()
FString Name;
};
//...
//Set your struct variables
FTestCppStruct TestStruct;
TestStruct.Name = TEXT("George");
TestStruct.Index = 5;
TestStruct.SomeNumber = 5.123f;
FGESEmitData EmitData;
EmitData.bPinned = true; //or false
EmitData.Domain = TEXT("global.default");
EmitData.Event = TEXT("MyAwesomeEvent");
EmitData.WorldContext = WorldContextObject; //you need WCO from e.g. an actor or a world.
FGESHandler::DefaultHandler()->EmitEvent(EmitData, FTestCppStruct::StaticStruct(), &TestStruct);
I'm going to spend a few minutes to expose this so it's usable
going to combine it with the convenience receiver actor feature branch here: https://github.com/getnamo/global-event-system-ue4/tree/feature-base-component-receiver
Thanks a lot, works like a charm!
Merged to master with convenience actor component receivers (see https://github.com/getnamo/global-event-system-ue4/blob/master/Source/GlobalEventSystem/Public/GESBaseReceiverComponent.h & https://github.com/getnamo/global-event-system-ue4/tree/master/Content/GenericComponentReceivers). Now going to work on a bind to c++ lambda variant which should make the receiving side of c++ a bit easier.
Early release https://github.com/getnamo/global-event-system-ue4/releases/tag/0.7.0e closing issue. Re-open a new issue if some bugs crop up
For the start - I love this tool, both the concept execution. But I'd love use this system from code as well as BP. It was pretty easy to bind and emit an event withouth a param, but I'm trying to figure out - is there any straightforward way to use One Param version from C++?