Download

Dynamically inspecting/parsing a struct

I am looking for a way to dynamically parse through a struct. I had asked about this a year or two ago and had no success but I wanted to try again to see if someone had figured it out or if improvements have been made to the engine to support this.

To give an example of what I’m looking for, imagine a struct with three entries. The first is an enum, the second is a string and the third is another struct. I wish to build UMG widgets based on the elements in this struct.

I want to be able to reference this struct as a class and loop through each entry. For each value, I need to get the type (even as a string would work). So in the above example, I would first get an enum then build a UMG widget using the enum as a drop down. Then I would get a string and I would build a text field in the widget. Finally I’d get another struct and I would need to rerun the function using the new struct instead.

Think of it like I am defining a form for a user to fill out, created in a struct. Instead of having to manually update the UMG for every new element, it would be amazing if I could create a way to perform this dynamically.

Does anyone have any thoughts on this? I’d rather not abandon the structs if I don’t have to but if there’s another non-struct method I’d consider it.

Thanks

Just set your struct as a variable on the widget, set it from wherever you get the data. Then you can break the struct into its pins (just like a vector node). From those pins, you could then set the data in your form.
When the user updates the textbox (or whatever), call the function you used to set up the widget. You could then save the struct to wherever you need like any other variable.

Hopefully I explained that well enough?

Hmm, but that’s not dynamic interpretation, that’s just manually taking each entry in the struct and manually adding widget contents for them, which is what I was trying to avoid

In C++ is possible to cast the struct property to UStructProperty* pointer then iterate through its members and values, but in Blueprints I have no idea.

Ohhh, that’s very interesting! That could work out well! Thank you!

Are you trying to parse a struct or a datatable. I’ve been using bps to read through an amino sequence (string) and build a 3d modeled amino acid with parameters referenced from a datatable (each row named after a letter in the amino’s sequence).