Unable to add UWidget subclass to the viewport via BP?

So as per Nick’s answer here:

You should inherit from UWidget, not UUserWidget.

, I’ve subclassed UWidget for my custom composite widget to be placeable in the designer.

Everything’s working fine, except I can’t add an instance of my UWidget to the viewport via BP, because the Create Widget node is explicitly looking for UUserWidget children.

Is there a particular reason for this? It seems counter productive to have to wrap my UWidget inside an editor-created UUserWidget to be able to display it via Blueprint.

It looks possible to change the Create Widget node to take in UWidget subclasses, and in UWidgetBlueprintLibrary::Create add some special case logic to handle UUserWidget-specific functionality.

I can see a PlayerContext is being set on UUserWidgets, but that member doesn’t exist on UWidgets directly. I’ve not yet had a chance to look at what it is used for to see if it is necessary to add it to UWidget, so there’s that, but otherwise I can’t see a good reason why it wouldn’t work.

If there’s no reason beyond ‘we didn’t yet need it ourselves’, I’m working on a PR for it and will submit it when it’s done. :slight_smile: