Download

Where to store logical constants

Hello everyone,

I have various constants (e.g a constant uint8 TileSize) that I need to access in my c++ code as well as in my blueprints. Where should I best store such data so that I can modify it from editor (if possible a big plus but not extremely important) and can access it from both c++ and blueprints?

Thank you
Bugmee

UDataAsset:

But with UDataAsset I now need to have a reference to that specific asset everytime I want to access those constants, right? I can’t just do


UMyConstants::TileSize

in order to get the tile size. Is there a way to get access to the constants without having to store a reference to a specific DataAsset everywhere?

Is this also appropirate for NPC dialogue and stuff like that?

You said you want to edit default values on the editor.
​​​For that you need an asset containing a default object…

Otherwise I would just create a static class and a function library to change static variables from Blueprints when needed. And forget about editing defaults from editor UI.