Posted October 20, 2023 by TheCodeCollective
#UI
Author: Matthew Chadwick
For CyberSiege, we wanted the player the have access to a Build menu , where they could purchase and place different defenses to help them in the waves. The problem was that we needed a single class that could contain information about the defense, such as the name, a picture, and the cost of the defense. Without this object, the player would have a hard time planning where certain defenses should go and have trouble purchasing a defense in the first place. To solve this, I utilized the Tile List Entry class in UE4 and made exactly what we needed, a single class that presented all of the pertinent information to the player.
Before creating the actual tile list entry class, you need to create a structure that holds the data for the tile. You then need to create a class that derives from the base object that will only hold your data structure. Once these two steps are completed, I was finally able to create the class that would act as our tile list entry. I didn't directly derive a class from tile list entry, I instead derived our class from the base widget.
To make the class useable in a Tile List, I implemented the User Object List Entry interface, which enabled me to pass our data structure class to the Tile List when a new entry was added to it. Whenever a tile entry is created, the OnListItemObjectSet event is called, which is where we get the data from our object class and use that data to set the different elements of our tile list entry. After the elements of our tile list entry are set, the final UI object is then added to our list and becomes accessible to the player. This allows for a relatively detailed presentation of the defense options available to the player and allows them to make an informed decision when placing defenses in the world.