UE4DemoGameModeBase.cpp 541 字节
// Copyright Epic Games, Inc. All Rights Reserved.


#include "UE4DemoGameModeBase.h"

void AUE4DemoGameModeBase::BeginPlay()
{
	Super::BeginPlay();
	ChangeMenuWidget(StartingWidgetClass);
}

void AUE4DemoGameModeBase::ChangeMenuWidget(TSubclassOf<UUserWidget>NewWidgetClass)
{
	if (CurrenWidget!=nullptr)
	{
		CurrenWidget->RemoveFromParent();
		CurrenWidget = nullptr;
	}
	if (NewWidgetClass!=nullptr)
	{
		CurrenWidget = CreateWidget(GetWorld(), NewWidgetClass);
		if (CurrenWidget!=nullptr)
		{
			CurrenWidget->AddToViewport();
		}
	}
}