Adding a widget

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

216477-widget1.png

I thought this would be equivalent logic through scripting

Hi there. For this, one equivalent way that I found was to do the following:

  1. 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.

  2. 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.

  1. 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.

216509-widget-class-variable.png

If you would like to see my [basic implementation][5], I’ve placed it on github.