일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- listen server
- gas
- gameplay ability system
- 보안
- local prediction
- stride
- C++
- Unreal Engine
- 언리얼엔진
- animation
- unity
- gameplay effect
- Multiplay
- 게임개발
- 게임 개발
- CTF
- rpc
- level design
- UI
- Aegis
- gameplay tag
- widget
- attribute
- photon fusion2
- os
- MAC
- 유니티
- Replication
- 언리얼 엔진
- ability task
Archives
- Today
- Total
Replicated
[Drag Down] 매치메이킹 UI 본문


방 생성은 룸 이름을 넣어서 가능

Find Room 하면 현재 존재하는 룸의 리스트를 보여줌
Join 시 방에 입장 가능

블루프린트 구조


Create Room의 경우 Editable Text에서 텍스트를 읽어와서 룸 생성 리퀘스트

룸 엔트리는 이렇게 생겼는데
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Subsystem/DDHttpApiSubsystem.h"
#include "DDRoomEntryWidget.generated.h"
/**
*
*/
UCLASS()
class DRAGDOWN_API UDDRoomEntryWidget : public UUserWidget
{
GENERATED_BODY()
public:
virtual void NativeConstruct() override;
UFUNCTION(BlueprintCallable)
void SetRoomEntryWidget(FRoomSummary RoomSummary);
UFUNCTION()
void JoinRoom();
protected:
UPROPERTY(meta = (BindWidget))
TObjectPtr<class UTextBlock> TxtRoomName;
UPROPERTY(meta = (BindWidget))
TObjectPtr<class UTextBlock> TxtHostUserName;
UPROPERTY(meta = (BindWidget))
TObjectPtr<class UTextBlock> TxtPlayerCount;
UPROPERTY(meta = (BindWidget))
TObjectPtr<class UButton> BtnJoinRoom;
FString RoomID;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI/DDRoomEntryWidget.h"
#include "Components/Button.h"
#include "Components/TextBlock.h"
#include "DragDown.h"
void UDDRoomEntryWidget::NativeConstruct()
{
if (BtnJoinRoom)
{
BtnJoinRoom->OnClicked.AddDynamic(this, &UDDRoomEntryWidget::JoinRoom);
}
}
void UDDRoomEntryWidget::SetRoomEntryWidget(FRoomSummary RoomSummary)
{
RoomID = RoomSummary.RoomId;
if (TxtRoomName)
{
TxtRoomName->SetText(FText::FromString(RoomSummary.RoomName ));
}
if (TxtHostUserName)
{
TxtHostUserName->SetText(FText::FromString(RoomSummary.HostUserName));
}
if ( TxtPlayerCount )
{
FString Count = FString::Printf(TEXT("%d / %d"), RoomSummary.CurrentPlayerCount, RoomSummary.MaxPlayers);
TxtPlayerCount->SetText(FText::FromString(Count));
}
UE_LOG(LogDD, Log, TEXT("Room: %s, Host: %s, Players %d - %d"),
*RoomSummary.RoomName,
*RoomSummary.HostUserName,
RoomSummary.CurrentPlayerCount,
RoomSummary.MaxPlayers);
}
void UDDRoomEntryWidget::JoinRoom()
{
UDDHttpApiSubsystem* HttpSubsystem = GetGameInstance()->GetSubsystem<UDDHttpApiSubsystem>();
if (HttpSubsystem == nullptr)
{
UE_LOG(LogDD, Error, TEXT("No UDDHttpApiSubsystem"));
}
FString IP = HttpSubsystem->GetIP();
int32 Port = FCString::Atoi( *HttpSubsystem->GetPort() );
HttpSubsystem->SendJoinRoomRequest(RoomID, IP, Port);
}
FRoomSummary 읽어서 위젯 세팅할 수 있도록 코드 작성

런타임에 엔트리가 추가될 수 있도록 구성
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Subsystem/DDHttpApiSubsystem.h"
#include "DDRoomListWidget.generated.h"
/**
*
*/
UCLASS()
class DRAGDOWN_API UDDRoomListWidget : public UUserWidget
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
void SetRoomList(TArray< FRoomSummary > RoomSummries);
protected:
UPROPERTY(meta = (BindWidget))
TObjectPtr<class UVerticalBox> VerticalBox;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
TSubclassOf<class UDDRoomEntryWidget> EntryWidgetToList;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI/DDRoomListWidget.h"
#include "UI/DDRoomEntryWidget.h"
#include "Components/VerticalBox.h"
#include "DragDown.h"
void UDDRoomListWidget::SetRoomList(TArray<FRoomSummary> RoomSummries)
{
VerticalBox->ClearChildren();
if ( EntryWidgetToList == nullptr )
{
UE_LOG(LogDD, Log, TEXT("UDDRoomListWidget::SetRoomList - No Widget To List"));
}
if ( VerticalBox == nullptr )
{
UE_LOG(LogDD, Log, TEXT("UDDRoomListWidget::SetRoomList - No Vertical Box"));
}
for ( FRoomSummary& RoomSummary : RoomSummries )
{
UDDRoomEntryWidget* EntryWidget = NewObject<UDDRoomEntryWidget>(this, EntryWidgetToList);
if (EntryWidget == nullptr)
{
UE_LOG(LogDD, Log, TEXT("UDDRoomListWidget::SetRoomList - WidgetToList Creation Failed"));
return;
}
VerticalBox->AddChild(EntryWidget);
EntryWidget->SetRoomEntryWidget(RoomSummary);
EntryWidget->Padding = 5.0f;
}
}
버티컬 박스 안에 런타임에 위젯이 추가될 수 있도록 구성
주의할 점은, AddChild를 해야 에셋 바인딩이 되어서 (Construct 시점 문제)
그 이후에 위젯 내용 설정을 해주는 함수를 써야 함
'언리얼 엔진 > Drag Down' 카테고리의 다른 글
[Drag Down] GameState에서 Player Idx 및 Ready 상태 관리하기 (PlayerState로 분리 예정) (0) | 2025.05.18 |
---|---|
[Drag Down] 플레이어 UI 기획 (각 플레이어 Z축 위치, 이름 표기) (0) | 2025.05.12 |
[Drag Down] 자체 매치메이킹 연동 성공 (Unreal <-> Spring Boot) (0) | 2025.05.11 |
[Drag Down] 메시 변경 UI, USceneCaptureComponent2D (0) | 2025.05.07 |
** [Drag Down] 스켈레탈 메시 병합 및 붙이기 (Skeletal Mesh Merging & Attach) ** (0) | 2025.05.03 |