CreatedWidget doesn't show up after adding to viewport...

Hello,

When HUD calls the BeginPlay method for a customized AuthenticationUserWidget by inheriting the UserWidget class in C++, after creating a widget through CreateWidget (GetWorld(), AuthenticationSubclass);.

I think something went wrong during the test of simply printing the widget on the screen through the AddToViewport() method.

Obviously at the time of debug, all components do not return nullptr and the editor starts with good reference, but the widget is not visible on the screen at all.

It was originally intended to add a ScaleBox component underneath the Canvas Panel on the viewport screen, add another Border underneath the component, and change the background color to white to see if the actual widget is displayed on the screen.

But I can’t even solve this process, so I put a question here.

Of course, I also looked for ways to do it using pure C++, or Slate module, but it seems a little complicated, and after inheriting AuthenticationUserWidget with WidgetBlueprint, UPROPERTY (Meta=…)… ) After binding each other with keywords, secondarily to check if they are implemented well.

I tried to check on the editor to see if the actual bAutoize changed to true by referring to Canvas Panel Slot, but this was also not reflected.

I don’t think I can figure out where the problem came from.

The following are the processes that take place.

  1. Object Initializer () All classes

  2. HUD
    ->BeginPlay()
    ->CreateWidget()
    ->AddToViewPort()

3 AuthenticationUserWidget
->NativeConstruct()

We move on to this stage.

I will attach the details as the picture below.
I’d really appreciate your help :slight_smile:

[Structure]

I’m sorry, the Unreal Forum says that new users can only upload 1 image. It’s cumbersome, but I share it as a compressed file and upload it.

Hello! You cant simply construct objects and fill props with them to make custom UMG work. Here some simple examples, you can check GitHub - klauth86/UE_Plugin_WhirlPanels. Whole list of methods should be override to make custom UMG. In the sense of parts - there are mainly two parts: Slate class, Widget Slot + Widget Compponent. Of course, if there is no need in custom Slate class, then it is ok just to create Widget Slot + Widget Compponent and override similar things to store Slate hierarchy needed…

Hello,

Finally, I checked what the problem was in a week. Coincidentally, I searched Github to see if anyone had similar intentions as me, and one person really thankfully posted an example source.

There was only one difference in the sauce above.
Using SWidget,
It simply calls the RebuildWidget() method into NativeConstruct().

Depending on whether or not you return the SWidget of the RebuildWidget() method, it seems to be an important condition for implementing C++ pure UserWidget.

Anyway, I’m really happy that it worked out well.

If you have someone who does this in pure C++,
First of all, GameInstance::Init()
Make sure you have UserWidget::RebuildWidget(), UserWidget::NativeConstruct().

I will attach the link I found on Github at the bottom.

Also, the code I wrote is as follows.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.