Widget doesn't spawn 'SpawnActor failed because no class was specified'

It was being created well until now, but when the editor was shut down and opened again during the Unreal Editor compile, it suddenly couldn’t create a widget.

LogSpawn: Warning: SpawnActor failed because no class was specified

I didn’t work on the widget part.

When I rewind the c++ file, the missing widget does not return.

If you turn the debug, the pointer address exists properly.

And even if you add widget with blue print instead of C++, it will not be generated.

It’s the same when I create a new widget and try it.

UPROPERTY(VisibleInstanceOnly, Category = "Widget")

TSubclassOf<UUserWidget> MainMenuWidgetClass;

​

UPROPERTY(VisibleInstanceOnly, Category = "Widget")

class UWG_MainMenu* MainMenuWidget;
static ConstructorHelpers::FClassFinder<UUserWidget> BP_Main(TEXT("/Game/Widget/BPWG_mainMenu"));

​

if (BP_Main.Succeeded())

MainMenuWidgetClass = BP_Main.Class;
if (IsValid(MainMenuWidgetClass))

{

    MainMenuWidget = Cast<UWG_MainMenu>(CreateWidget(GetWorld(), MainMenuWidgetClass));

    if (MainMenuWidgetClass != nullptr)

    {

        MainMenuWidget->AddToViewport(0);

    }

}