I’m trying to understand how I can do the equivalent of adding a widget component and setting the class via scripting, I must be misunderstanding widget objects?
If I add the widget as a component and set the class like this, I get the desired output
I thought this would be equivalent logic through scripting
Hi there. For this, one equivalent way that I found was to do the following:
Create the widget component using the Add Widget Component (as you’ve done above. I’ve stored mine in an actor that I called WidgetForUI). Afterwards, I used the [Create Widget][1] node to create a new widget of a class.
Once this is done, you can set the widget you wish to use by grabbing the widget component and using the function [Set Widget][2]. From there I set the draw size.
I use a User Widget class variable to create the widget for the widget component. This allows for whoever is placing the actor to select which widget they would like to display.
If you would like to see my [basic implementation][5], I’ve placed it on github.