(Only using 4.14 because at the moment 4.15 and 4.16 seem to have issues finding multiplayer sessions).
I have a really large struct I’m using to store data for abilities. The name, cost, the effects that get executed and some other values. Name is just a string, cost is a reference to another struct with a set number of elements and effects is an array of references to other structs containing an unknown number of elements.
Inside the editor, I can create a new variable on an actor and set the type to be my struct. From here, I can easily modify all the values, add elements to arrays and set the data as needed. This is all well and good but I wish to implement this functionality in game as well - I want players to be able to create these abilities.
In order to do this, I will need some UMG widgets to handle the interface. I could do this by hard-coding everything for each section of the struct. But I will be making many changes to this struct and it would be nice to not need to change this widget every time.
What I would LIKE to do is feed this struct into a function to interpret it. For some pseudocode (I am using blueprint but this should still translate fine):
interpretStruct(structure reference, parent widget reference)
{
for each element in struct
{
switch on element type (this is the part I'm unsure if possible)
{
if it's a struct
{
create a vertical box child widget under parent
call interpretStruct with found struct and newly created widget
}
else if it's a string or if it's an int or if it's a float
{
create a new text box and add it to parent widget
}
else if it's a boolean
{
create a new checkbox and add it to parent widget
}
}
}
}
The above isn’t super well thought out and I’d probably need to do a bit to fix it and make it work but it should be enough to get the idea across.
Essentially, I want to create a function to dynamically build a UMG widget to allow players to enter data for a struct the same way you can in the editor, as seen here:
(stole the image from another post, this is not my struct/data).
Is this possible to any degree? If not, are there any better ways to tackle this other than just hardcoding everything?