Set default level in c++

I want to set SetGameDefaultMap in my c++ class, not in ProjectSettings->Map & Modes. I want to create a class that will set this default project parameters and be executed after game is started.

h:

UCLASS()
class CARDGAME_API MySettings : public UGameMapsSettings
{
     	GENERATED_BODY()
 public:
       	MySettings();
};

cpp:

MySettings::MySettings () {
	SetGameDefaultMap("???");
}

Create class NativeGameInstance derived from UGameInstance and override Init

#pragma once

#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "GameMapsSettings.h"
#include "NativeGameInstance.generated.h"

/**
 * 
 */
UCLASS()
class CARDGAME_API UNativeGameInstance : public UGameInstance
{
	GENERATED_BODY()
	
public:
	virtual void Init() override;
};

#include "NativeGameInstance.h"

void UNativeGameInstance::Init()
{
	Super::Init();

	UGameMapsSettings::SetGameDefaultMap(TEXT("/Game/NewMap2.NewMap2"));
}

*.Build.cs add EngineSettings module

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EngineSettings" });

ProjectSettings → Maps&Modes → Game Instance Class: NativeGameInstance

If any problem let me know. My discord Andrew Bindraw #9014

Hi thx for you answer, I’ve got real problem to test it. I wanted to selected map (specified in c++ class) to be shown after I hit Play (standalone game) button from unreal editor. Currently even after adding this code after I play my game map that is played is my current selected map in editor. How I can test it, because maybe I don’t know how editor works…