How to add arbitrary metadata to a class

Good day, everyone

I am creating a tower defence game, blueprint only. I have a set of buildings that can be built on a “buildable” tile. When the player clicks on a tile then a UMG menu pops up to give the player the options of what he can build there. Each button contains a class reference and when the player clicks on it, it will send that info to the tile and then the tile creates an instance of that class. Screenshots below:

I want to show a custom text and image on each button. In an ideal world I would be able to add that data as static variables to the class, which will be initialized without needing a class instance. However, blueprint doesn’t support them. So my question is this: how can I simulate such behaviour?

Options that I thought of:

  • Creating a multi-dimensional array of the data, but this means that I will have to manually add everything. It also breaks encapsulation
  • Creating a custom class or struct which holds the metadata and class reference. This does mean I can use a single dimension array, however, this still requires manually adding all data and breaks encapsulation, so it’s equally bad.

I want to stick to good programming practices. All help will be greatly appreciated, because I have been looking for an answer for a long time.

I have just encountered another similar situation. I have a set of lights that I want to gradually make brighter. For each light I would set the intensity to 0 and then increase it (via finterpto) to its original intensity. I could save the original intensity in an external variable, but it would be best to attach that data to the light object itself, in case I need it somewhere else later.

This makes me think of JavaScript. In JavaScript I could simply attach data to an object, like: currLight.originalIntensity = 2000. I can’t shake the feeling that there must be something similar in Blueprint.