일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- map design
- gameplay tag
- 언리얼 엔진
- Aegis
- listen server
- 언리얼엔진
- Unreal Engine
- gameplay ability system
- rpc
- attribute
- 게임 개발
- ability task
- local prediction
- animation
- photon fusion2
- 보안
- 유니티
- gas
- gameplay effect
- Multiplay
- UI
- Replication
- os
- unity
- stride
- 게임개발
- CTF
- nanite
- network object pooling
- MAC
Archives
- Today
- Total
Replicated
[Drag Down] 메뉴 만들기 #1 커스텀 UserSetting, 메뉴 토글 본문
이 세팅이랑 DLSS 세팅할 거다
UGameUserSettings상속해서 클래스 만들어주고
DefaultEngine.ini에 설정 추가
이래야 기본 세팅이 DDUserSettings로 변경됨
GameUserSettings만으로도 잘 작동할 것 같긴 하지만, GameInstanceSubssytem으로 래핑하는게 더 유연할 것 같다.
void UDDGameSettingSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);
UserSettings = Cast<UDDUserSettings>(GEngine->GetGameUserSettings());
if ( UserSettings )
{
UE_LOG(LogDD, Log, TEXT("UserSettings Found"));
}
else
{
UE_LOG(LogDD, Error, TEXT("UserSettings not Found"));
}
}
발견! 일단 ini 설정은 잘 된 거 같다
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameUserSettings.h"
#include "DDUserSettings.generated.h"
/**
*
*/
UCLASS()
class DRAGDOWN_API UDDUserSettings : public UGameUserSettings
{
GENERATED_BODY()
public:
UDDUserSettings();
virtual void ApplySettings(bool bForce = false) override;
UFUNCTION(BlueprintCallable)
FORCEINLINE float GetBGMVolume() { return BGMVolume; }
UFUNCTION(BlueprintCallable)
void SetBGMVolume(float InBGMVolume);
UFUNCTION(BlueprintCallable)
FORCEINLINE float GetSFXVolume() { return SFXVolume; }
UFUNCTION(BlueprintCallable)
void SetSFXVolume(float InSFXVolume);
protected:
UPROPERTY(Config)
float BGMVolume;
UPROPERTY(Config)
float SFXVolume;
};
커스텀 GameUserSettings이다
일단 기본 클래스에서 그래픽 요소는 제공을 하고, 거기에 사운드 틀만 짜놨다
// Fill out your copyright notice in the Description page of Project Settings.
#include "Setting/DDUserSettings.h"
UDDUserSettings::UDDUserSettings()
{
BGMVolume = 1.0f;
SFXVolume = 1.0f;
LoadConfig();
}
void UDDUserSettings::ApplySettings(bool bForce)
{
Super::ApplySettings(bForce);
SetBGMVolume(BGMVolume);
SetSFXVolume(SFXVolume);
}
void UDDUserSettings::SetBGMVolume(float InBGMVolume)
{
BGMVolume = FMath::Clamp(InBGMVolume, 0.0f, 1.0f);
SaveConfig();
}
void UDDUserSettings::SetSFXVolume(float InSFXVolume)
{
SFXVolume = FMath::Clamp(InSFXVolume, 0.0f, 1.0f);
SaveConfig();
}
SaveConfig, LoadConfig시 DefaultEngine.ini에서 알아서 할 거다
이제 다음은 UI 인풋 처리이다
탭을 누르면 메뉴가 나타나고, 사라지고 하도록 할 것이다
게임 패드도 설정해주자
// Normal Widget
public:
void ToggleMenu();
void OpenMenu();
void CloseMenu();
// UMG 위젯 클래스 (블루프린트에서 설정)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "UI")
TSubclassOf<class UUserWidget> MenuWidgetClass;
UPROPERTY()
TObjectPtr<class UUserWidget> MenuWidget;
bool bIsMenuOpen;
};
void ADDPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
InputComponent->BindAction("OpenMenu", IE_Pressed, this, &ADDPlayerController::ToggleMenu);
}
void ADDPlayerController::ToggleMenu()
{
if (bIsMenuOpen) CloseMenu();
else OpenMenu();
}
void ADDPlayerController::OpenMenu()
{
if (MenuWidgetClass == nullptr) return;
if ( MenuWidget == nullptr )
{
MenuWidget = CreateWidget(this, MenuWidgetClass);
}
MenuWidget->AddToViewport(100);
FInputModeGameAndUI UIInputMode;
UIInputMode.SetWidgetToFocus(MenuWidget->TakeWidget());
SetInputMode(UIInputMode);
bShowMouseCursor = true;
bIsMenuOpen = true;
}
void ADDPlayerController::CloseMenu()
{
if ( MenuWidget )
{
MenuWidget->RemoveFromViewport();
}
FInputModeGameOnly InputMode;
SetInputMode(InputMode);
bShowMouseCursor = false;
bIsMenuOpen = false;
}
FName에 해당하는 인풋이 들어오면 플레이어 컨트롤러가 감지해서 메뉴를 띄워주거나, 닫는 코드이다
'언리얼 엔진 > Drag Down (캡스톤 디자인)' 카테고리의 다른 글
[Drag Down] Action 인풋 처리 (0) | 2025.04.22 |
---|---|
[Drag Down] 앞으로 해야 하는 거 간단히 정리 (0) | 2025.04.20 |
[Drag Down] 미끄러지는 길 (Physical Material + Surface type + Data Asset) (0) | 2025.04.17 |
** [Drag Down] Performance Enhancement of Network Object Pooling ** (0) | 2025.04.16 |
** [Drag Down] Network Object Pooling (Subsystem + Interface + GameMode + DataAsset) ** (0) | 2025.04.16 |