GameModeBase.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "MMOGameModBase.h"
void AMMOGameModBase::BeginPlay()
{
Super::BeginPlay();
MainMenu = CreateWidget<UUI_MainMenu>(GetWorld(), UUI_MainMenu::StaticClass());
if (MainMenu != nullptr)
{
MainMenu->ToggleMainMenu(true);
}
}
UI_MainMenu.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "UMG_Button.h"
#include "UI_MainMenu.generated.h"
/**
*
*/
UCLASS()
class PROJECTM_API UUI_MainMenu : public UUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(meta = (BindWidget))
UUMG_Button* B_NewGame;
UPROPERTY(meta = (BindWidget))
UUMG_Button* B_LoadGame;
UPROPERTY(meta = (BindWidget))
UUMG_Button* B_ExitGame;
UFUNCTION()
void ToggleMainMenu(bool bInput);
};
UI_MainMenu.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI_MainMenu.h"
void UUI_MainMenu::ToggleMainMenu(bool bInput)
{
if (bInput)
{
AddToViewport();
}
else
{
RemoveFromViewport();
}
}
This is the problem
MainMenu->ToggleMainMenu(true);
Debugging it, it arrives well to the AddToViewport(); function. But I don’t know why ican’t see it on the screen.
I already changed the game mode to my GameMode
I’m looking into this problem a lot right now, but I don’t know why it’s like this. I’ve regenerated the project file and rebooted it, but it doesn’t work at all. Help me!