Public Variables on Widget BP children?

I have created a widget bp with a couple of publicly editable variables. I then made that bp a child of another widget bp. At this point I can see the publicly editable variables under the default section of the details pane when I select the child widget. However, if I want to pull this new widget (that houses the initial widget with the exposed variables) into another widget, how do I “re-expose” those same variables?

Usually anonymous communication like you want is done via Interfaces or Widget Variable binding.

So, lets say… I create a widget with text in it. I bind the text so that I can type it in per instance. I pull that widget into another widget. I will see a variable for text where I can chose the text I want. However, what if I want to save this new widget into another widget and retain the ability to type in the text. How do I keep this variable public? Is this where the interface comes in?

I was able to solve this issue by simply event dispatching events such as “on state change.” This in effect re-exposes the event.

Did you figure this out? that’s exactly what I want to achieve.

An interface is a contract in programming that says “All things that use this interface can accept X input and do something with it”. It’s a way to de-couple things and still know they will accept input in a predictable fashion.

Set up an interface with the method SetMyVariable or whatever you want to call it. Set the widget class to use that interface. In your widget, implement SetMyVariable to do whatever logic you want. In this case, it would simply take the variable value in, and set it to it’s own private variable. You can also use a getter in this fashion (GetMyVariable).

You might be able to do this with public variables but I would suggest an interface to make your widget more portable and accessible from different parts of the project.


e: grammar