일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Module
- Console
- 코드리뷰
- topdownmove
- STL
- 네트워크 기초
- 언리얼엔진5 #언리얼 클라이언트 프로그래밍
- 툰쉐이딩
- Unreal
- CS50
- 언리얼 엔진5 #언리얼 클라이언트 프로그래밍
- C++
- 브론즈
- A* Algorithm
- Gas
- 순환 리스트
- leetcode
- Harvard
- 언리얼
- 오늘밤 세계에서 이 사랑이 사라진다 해도 #독후감 #오열
- CS
- 원카페#무인카페#카페추천#카페맛집
- 메테리얼
- UE_5
- build.cs
- 백준
- 폭설 #미친 날씨
- c++ 베이직
- Toon Shading
- 헤더 경로
- Today
- Total
WN_인생기록
[UE_5] 모듈 제작 -3 (메세지 출력(Notify,Dialog)) 본문
만약에 특정 기능에서 잘못된 입력이라던가 잘못된 결과가 나올시에 언리얼에서는 메세지 다이얼로그가 뜨는데, 이걸 띄우는걸 해보자.
https://docs.unrealengine.com/4.27/en-US/API/Runtime/Core/Misc/FMessageDialog/
FMessageDialog
[FMessageDialog](API\Runtime\Core\Misc\FMessageDialog) These functions open a message dialog and display the specified informations these.
docs.unrealengine.com
언리얼 문서는 이걸 통해서 확인이 가능하다.
if (NumOfDuplicates <= 0)
{
FText MsgTitle = FText::FromString(TEXT("Warning"));
FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(TEXT("Please enter a Valid Number")),&MsgTitle);
Print(TEXT("Please enter a Valid number"), FColor::Red);
return;
}
Open 이라는 기능을 통해서
EAppReturnType::Type FMessageDialog::Open( EAppMsgType::Type MessageType, const FText& Message, const FText* OptTitle )
EAppMsgType을 설정하고 (Ok, Yes or No) 텍스트를 저장하는데 FText 데이터형이다. FromString이라는 기능이 있어서 TEXT()를 통해서 string을 FText로 변환할 수 있다.
마지막 매개변수는 언리얼 메세지의 제목이라고 생각하면 된다.
Open 기능을 살펴보면 EAppReturnType이라는 데이터형으로 저장되어 있다.
그래서 나중에 DebugHelper 같이 편리하게 코드 만들어줄 헤더에 추가할려고 할때,
EAppReturnType::Type ShowMsgDialog(EAppMsgType::Type MsgType, const FString& Msg, bool bShowMsgAsWarning = true)
{
if (bShowMsgAsWarning)
{
FText MsgTitle = FText::FromString(TEXT("Warning"));
return FMessageDialog::Open(MsgType, FText::FromString(Msg), &MsgTitle);
}
else
{
return FMessageDialog::Open(MsgType, FText::FromString(Msg));
}
}
이런식으로 추가해주면 편하다.
https://docs.unrealengine.com/4.27/en-US/API/Runtime/Slate/Widgets/Notifications/SNotificationList/
SNotificationList
A list of non-intrusive messages about the status of currently active work.
docs.unrealengine.com
FSlateNotificationManager
A class which manages a group of notification windows
docs.unrealengine.com
이 둘을 보면 에디터에서 오른쪽 아래에 보면 나오는 알림창 같은걸 사용할 수 있다.
void ShowNotifyInfo(const FString& Msg)
{
// 들어온 메세지 NotificationInfo에 저장
FNotificationInfo NotifyInfo(FText::FromString(Msg));
// 설정
NotifyInfo.bUseLargeFont = true;
NotifyInfo.FadeOutDuration = 5.f;
// SlateNotifucationManager에서 추가하기
FSlateNotificationManager::Get().AddNotification(NotifyInfo);
}
이런식으로 디버그헬퍼에 추가해주면 쉽게 사용이 가능하다.
Manager를 통해 알림에 넣어주면 알아서 알림창이 뜨게 된다.
이렇게 되면 툴을 통한 메세지 출력이 전부 다 가능하다.
완료 되었을땐 노티파이가, 틀렸을땐 Warning 다이얼로그가 나오게된 셈이다.
'언리얼 개발 > 이것저것 테스트' 카테고리의 다른 글
[UE_5] 모듈 제작 -5 (엔진 메뉴 Extension) (0) | 2024.04.22 |
---|---|
[UE_5] 모듈 제작 -4 (Start with Editor Utility) (0) | 2024.04.22 |
[UE_5] 모듈 제작 -2 (에셋 복제) (0) | 2024.04.20 |
[UE_5] 모듈 제작 -1 (Debug Header) (0) | 2024.04.20 |
[UE_5] 모듈(Type,LoadingPhase) (0) | 2024.04.20 |