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.