Hello! I’m trying to make a shop UI where players can buy weapons. When I was writing out the blueprint for switching the text variable to say “purchased” when an item was bought I realized I had a bunch of variables. I also have a bunch of booleans to check if weapons had been purchased so that the player could not repeatedly buy the item. I was wondering if there was a more efficient way to handle these variables for the different weapons and their respective buy buttons and text.
you could use a object oriented approach, both in your code but also your UI. If you create a UMG widget that is generic it can contain the look, the price and toggle if it has been bought or not. Then in your data structure, you could use an enum representing the type of weapon and if it has been bought or not.
doing it like you are now will get painful when you start adding new types and tweaking the style, putting everything into a templated umg widget means change once and it applies to all items in your store
attached is a screenshot of one of my templated store buttons, it has a init function where i pass in the enum, and it loads the proper data, sets the price, then searches my save game to see if its been bought / etc
Do you have any examples or sources on how to do the data structure of the templated widgets that I could refer to?
I infact do! I made this series on data driven UMG - UNREAL ENGINE: Data Driven UMG - Part 1: Structs, DataTables & UMG - YouTube p.s I’d really like a upvote, accepted answer for that karma, wants me a forum badge
This is very helpful! Thank you so much!