Plugin: keeping an object alive for the whole game
I am developing a Plugin that exposes a network API.
The main entry point of this API is a plain C++ object named Client that represents a connection to a server.
Once the API user has created the Client (there usually is only one), I want this Client to persist across levels (the goal is to keep the connection open). Destruction of the Client should only occur if the user explicitly asks for it.
So far, I have found two ways to achieve this:
Both these options have worked fine so far, but they share a common problem: when using Play in Editor, the Client is kept alive after the Play session ends, which I do not want.
I am looking for a non-intrusive way to prevent the Client object from outliving a Play in Editor session. By non-intrusive, I mean that I want it to be transparent to the user of my plugin (i.e. they should not have to create a custom GameInstance to hold a reference to the Client, etc.).
Is this at all possible? Thanks in advance.
asked Mar 15 '17 at 02:46 PM in C++ Programming
There variues PIE events in FEditorDelegates which you can bind to, they are static, look up in constants:
remember to use #if WITH_EDITOR and make diffrent initiation code for editor and game builds
answered Mar 15 '17 at 07:55 PM
If you have someplace that runs any Tick/PerFrame logic, you could probably try something like this:
answered Mar 15 '17 at 06:16 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here