Plugin : Initialize protected, persistent object
I'm a Games Engineer student and currently developing a plugin. The plugin will be used through a BPFunctionLibrary. For the plugin I'll need an object (let's call it Watcher), that is created on Plugin StartUpModule() and can be accessed by all classes inside my plugin module. It's supposed to hold values like position, materials etc.
My first idea was to declare it inside my PluginModule.h and use the StartUpModule() method to create an instance of it. Since the StartUpModule() is called once, Watcher would be a Singleton as intended.
Inside the cpp:
Inside my functions of the BPFunctionLibrary.cpp I'd like to have access to the Watcher object to define different behaviour based on the values inside Watcher. Since Watcher is a member variable of my PluginModule, I need a reference to it. Where do I get it?
Or is there a better solution?
asked Nov 15 '17 at 03:26 PM in C++ Programming
My Solution was a Singleton, accessed through a static method
answered Nov 15 '17 at 09:41 PM
First of all insted of
As main issue, you eather need to get module class object form module manager:
Or create singleton in your module class so you can direcly refrence it, you cna look up in other modules in engine to see how it works, here example of HTTP:
and in CPP
I know you plan to do so with UObject, but i'm not sure if that is safe thing to do, so i recomand you to it with module class as most module classes in engine do.
answered Nov 15 '17 at 09:29 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here