Download

Developing a dynamic interface for filling out values in a Struct

I have a struct containing values that contains other structs with other values and even more structs with more values. It’s a big thing and singlehandedly defines the behavior of an actor in my game.

I want to create a UMG widget to effectively do the same thing you can do inside the editor when you create a variable with the type of this struct: Go through each entry in the struct and enter values for them. So my thoughts on this are as follows:

  1. Is it possible to “inspect” a struct? For example, in a blueprint, can I have a function that would accept any struct and pick out the pieces? I would need the number of elements, the data type for each element and the current value. If I can do this, I can have this dynamically create the UMG Widget for me and I don’t need to update it any time there’s a change to the structure.

I feel like this isn’t possible at the moment. So, moving on:

  1. Is it possible to have widgets update in real time in the editor? For example, if I have a widget that’s simply a label and a text box that will be used for pretty much every field in the struct. I can add this widget as a child to a main menu and I can use the main menu to specify what values will be used for the label in-game… but I won’t see it in the editor. I feel like I need a construction script for UMG widgets but I don’t think that exists. Effectively, I want to expose properties of a child widget for use within the parent widget so that I can see them in the editor.

If the above makes sense, you don’t need to read this next paragraph. But I feel like I’m explaining it poorly so I’ll try to clarify further. I make a widget. It’s a “border” containing a “text box”. The text box says “none”. I make another widget, it’s a border with a child widget of that first created widget. In this parent widget, I see the child with the text “none”. I can go to the child widget, create a text variable and bind the text element to the text variable. Then make the variable editable. In the parent widget, I can see the variable and I can modify the values. But no matter what I put in there, I will always see “none” for that text. Until I run the game and it actually uses the variable.

  1. Any other ideas as to how this can be tackled effectively?