Which class to choose to store const data globally accessible at editor-time and runtime?

I want to store data, that is “globally” accessible from C++ Code as well as from Blueprints. The data is going to be constant (at run-time, but settable at editor-time) and should be accessible at editor-time as well as run-time.

I stumbled upon the GameInstance, thinking this would be it, but this does not allow to access the data at editor-time, since the instance does not exist yet.

I read that GameInstances replace Singletons and Singletons would now be bad practice, but Singletons would offer the possibility to implement this. Is it really bad practice or - in this case - better practice?

In the Engine > General Settings, where one registers his Singleton class, I also stumbled upon the World Settings class, which is set in the same window. The data I want to store can be considered to describe objects that can be used throughout the world, so I thought this might be exactly what I want, but I can not seem to access this through blueprints.

I vaguely remember (I might be wrong) that an Epic Team member mentioned in a twich live stream, that the GameMode class is excellent to store data, that needs to be accessed “globally” for exactly my purpose… But storing the data in GameMode would be a rather vague interpretation of the data… It simply does not add to the GameMode…

There is also the option to inherit from the Actor class to create some kind of database, that would be accessible through the “Get All Instances of Class”-Node in blueprints (and thus also through C++) and place an Instance of the database in the level. But this appears to be a workaround to me.

There might be even more classes out there that would be suitable, but I would like to know what the epic team would consider best practice to store data in this case. I would like to not replicate the data throughout all objects that need them or pay CPU workload to access the data. Ideally, I would like to use a simple “Get” Method to the data. So my question is: How to achieve this best?

This is a question that comes back often. The best answer I found was this one here from Ben Zeigler

and roughly the same answer here for blueprints

Also this answer here is pretty good

1 Like

Just as an additional notice to people who choose a singleton:

Here is a wiki entry about implementing a singleton as described in the links above: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums!

Also: When you register your own singleton class in the engine settings, you need to restart your engine, so that the engines reflects your new configuration.