Unreal Engine – Matchmaking
void AMyLevelScriptActor::BeginPlay(){
Super::BeginPlay();
MyLevelScriptActor.cpp
readyToHost = false;
serversList = new TArray<FSessionInfo*>();
GetWorld()->GetTimerManager().SetTimer(serverListTimerHandle,
this, &AMyLevelScriptActor::OnUpdateServerList, 2, true);
if (MatchmakingWidgetClass) {
MatchmakingWidget = CreateWidget<UUserWidget>(GetWorld(),
MatchmakingWidgetClass);
MatchmakingWidget->AddToViewport();
UButton* connectButton = Cast<UButton>(MatchmakingWidget
-
>GetWidgetFromName(TEXT("ConnectButton")));
if (connectButton) {
connectButton->OnClicked.AddDynamic(this,
AMyLevelScriptActor::OnConnectClicked);
&
}
UButton* hostButton = Cast<UButton>(MatchmakingWidget
>GetWidgetFromName(TEXT("HostButton")));
-
if (hostButton) {
hostButton->SetIsEnabled(false);
hostButton->OnClicked.AddDynamic(this,
&AMyLevelScriptActor::OnHostClicked);
}