Download

Create widget asset from GameInstance

I’m attempting to modify my code to remove string references to BP widget classes used by ConstructorHelpers::FClassFinder<>

For example, I have a BP widget **SpecialMenuChild **with a C++ parent of USpecialMenuParent.

In *GameInstance *I declare

UPROPERTY()
TAssetSubclassOf<class USpecialMenuParent> SpecialMenuChild

In *GameInstance *I declare

UFUNCTION()
ShowSpecialMenu()

It’s implementation includes …

USpecialMenuParent* SpecialMenu = CreateWidget<USpecialMenuParent>(this, SpecialMenuChild.LoadSynchronous())

Unfortunately, this results in NULL SpecialMenu.

I must be missing a step.

Can anyone throw me a bone?

Cheers, Grover.

No need to load the asset directly, just have TSubclassOf<UUserWidget> in header, and use this class when you create the widget.

That’s no help STRiFE.x

How about a little more detail please.

For what it’s worth, I also tried

UPROPERTY(EditDefaultsOnly)
TSubclassOf<class UUserWidget> SpecialMenuChild;

and then
UUserWidget* SpecialMenu = CreateWidget<UUserWidget>(this, SpecialMenuChild);

No bananas.

I’ll go back to using ClassFinder and string references to assets. Which we’re advised NOT to do but I can’t waste any more time on this frustration.

Are you not just forgetting to add it to the viewport?

Na, I’m only including the relevant code here. I test for null, setowningplayer etc.
Before I post to the forums I try everything I can possibly think of and am only here as a last resort.
I can get around this by simply using ClassFinder and will revisit another day.
However, I do have another problem, which I can’t work around and am willing to pay $50 (Aus) for help. It’s trivially simply and will take the right person 30 seconds to diagnose.
I will post on the forums tonight.