Service manager lifetime and ownership in Unreal; best practice.

We are currently using a GameInstanceSubsystem to manage the lifetime and accessibility of a C++ service management class instance (read: shared_ptr object) from a pure C++ library. This binds the lifetime of the object to that of the GameInstanceSubsystem. We are also taking advantage of getting the subsystem via a game instance’s GetSubsystem, so that we get that sort of singleton, global, access of that subsystem that own’s our object.
We would like to move the lifetime of the GameInstanceSubsystem’s object, our instance of our class, to an earlier initialization.

Our new solution is to, instead, is to inherit directly from the UObject class, then this allows us to instantiate that UObject anywhere, even dynamically in blueprints.

But I was wondering if there is a more elegant way to do this?

you could go with an Engine subsystem? I think it’s called?

This is a strong consideration. Thanks!

1 Like