当前位置: 首页 > news >正文

Unreal Engine 5 C++: 插件编写03 | MessageDialog

在虚幻引擎编辑器中编写Warning弹窗

准备工作

FMessageDialog These functions open a message dialog and display the specified informations there.

EAppReturnType::TypeUnreal Engine 中用于表示应用程序对话框(如消息对话框)返回结果的枚举类型。具体来说,当你使用 FMessageDialog::Open 或类似函数显示一个对话框时,用户的选择(例如点击“确定”、“取消”、“是”、“否”等按钮)会以 EAppReturnType::Type 的形式返回。这使得开发者能够根据用户的选择执行相应的逻辑。

EAppReturnType 是一个枚举类,其定义可能类似于以下内容:

namespace EAppReturnType
{enum Type{No,Yes,YesAll,NoAll,Cancel,Ok,Retry,Continue};
}

示例代码1

if (NumOfDuplicates<=0) {//Print(TEXT("Pls enter a valid number"), FColor::Red);FText MsgTitle = FText::FromString(TEXT("Warning"));FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(TEXT("Please enter a valid number")), &MsgTitle);return;
}

插件效果1

插件效果2

——————————编辑器右下角slate notification的效果————————————

A list of non-intrusive messages about the status of currently active work.

non-intrusive messages

非侵入性的消息,意味着这些消息不会干扰用户的操作或体验,通常是轻量级的提示或通知。

准备工作:需要的header file

https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Slate/Framework/Notifications/FSlateNotificationManager?application_version=4.27

A class which manages a group of notification windows

https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Slate/Widgets/Notifications/SNotificationList?application_version=4.27

A list of non-intrusive messages about the status of currently active work.

示例代码2

#pragma once
#include "Misc/MessageDialog.h"
#include "Widgets/Notifications/SNotificationList.h"
#include "Framework/Notifications/NotificationManager.h"void Print(const FString& Message, const FColor& Color)
{if (GEngine){GEngine->AddOnScreenDebugMessage(-1, 8.f, Color, Message);}
}void PrintLog(const FString& Message)
{UE_LOG(LogTemp, Warning, TEXT("%s"),*Message);
}EAppReturnType::Type ShowMsgDialog(EAppMsgType::Type MsgType, const FString& Message, 
bool bShowMsgAsWarning = true) 
{if (bShowMsgAsWarning == true) {FText MsgTitle = FText::FromString(TEXT("Warning"));return FMessageDialog::Open(MsgType, FText::FromString(Message), &MsgTitle);//return FMessageDialog::Open(MsgType, FText::FromString(TEXT("Warning: ") + Message));}else{return FMessageDialog::Open(MsgType, FText::FromString(Message));}
}void ShowNotifyInfo(const FString& Message)
{FNotificationInfo NotifyInfo(FText::FromString(Message));NotifyInfo.bUseLargeFont = true;NotifyInfo.FadeOutDuration = 7.f;FSlateNotificationManager::Get().AddNotification(NotifyInfo);
}
	if (Counter > 0){ShowNotifyInfo(TEXT("Successfully duplicated" + FString::FromInt(Counter) + "files"));//Print(TEXT("Successfully duplicated" + FString::FromInt(Counter) + "files"), FColor::Green);}

相关文章:

  • 鸿蒙HarmonyOS开发生态
  • 流水线并行(Pipeline Parallelism)原理详解
  • 软考中级网络规划设计师已过,分享一些备考心得
  • 推荐2个国内优秀的物联网平台
  • 生信初学者教程(十二):数据汇总
  • 认识联合体和枚举
  • 从零开发操作系统
  • PostgreSQL的扩展(extensions)-常用的扩展-pgstattuple
  • 鸿蒙开发(NEXT/API 12)【硬件(获取智慧出行连接状态)】车载系统
  • 通过人工智能AI大模型定制的完美旅游行程
  • 双指针---(部分地更新)
  • 基于JAVA springboot+mybatis智慧生活分享平台设计和实现
  • CS 工作笔记:SmartEdit 里创建的是 CMS Component
  • 调用飞书接口导入供应商bug
  • Vue3 工具函数(总结)
  • 《Java8实战》-第四章读书笔记(引入流Stream)
  • axios请求、和返回数据拦截,统一请求报错提示_012
  • C# 免费离线人脸识别 2.0 Demo
  • CSS3 聊天气泡框以及 inherit、currentColor 关键字
  • express.js的介绍及使用
  • IE报vuex requires a Promise polyfill in this browser问题解决
  • mac修复ab及siege安装
  • PHP 7 修改了什么呢 -- 2
  • python学习笔记-类对象的信息
  • 安装python包到指定虚拟环境
  • 使用权重正则化较少模型过拟合
  • 收藏好这篇,别再只说“数据劫持”了
  • 微信开源mars源码分析1—上层samples分析
  • ​什么是bug?bug的源头在哪里?
  • #pragma pack(1)
  • #我与Java虚拟机的故事#连载04:一本让自己没面子的书
  • $GOPATH/go.mod exists but should not goland
  • ( )的作用是将计算机中的信息传送给用户,计算机应用基础 吉大15春学期《计算机应用基础》在线作业二及答案...
  • (02)Cartographer源码无死角解析-(03) 新数据运行与地图保存、加载地图启动仅定位模式
  • (Java数据结构)ArrayList
  • (Redis使用系列) Springboot 整合Redisson 实现分布式锁 七
  • (二)Eureka服务搭建,服务注册,服务发现
  • (附源码)spring boot球鞋文化交流论坛 毕业设计 141436
  • (附源码)流浪动物保护平台的设计与实现 毕业设计 161154
  • (六)c52学习之旅-独立按键
  • (十六)串口UART
  • (转) RFS+AutoItLibrary测试web对话框
  • (转)c++ std::pair 与 std::make
  • (转)Java socket中关闭IO流后,发生什么事?(以关闭输出流为例) .
  • (转)总结使用Unity 3D优化游戏运行性能的经验
  • .bat批处理(三):变量声明、设置、拼接、截取
  • .NET 6 在已知拓扑路径的情况下使用 Dijkstra,A*算法搜索最短路径
  • .NET CF命令行调试器MDbg入门(三) 进程控制
  • .net 调用海康SDK以及常见的坑解释
  • .NET 事件模型教程(二)
  • .NET委托:一个关于C#的睡前故事
  • /dev/sda2 is mounted; will not make a filesystem here!
  • @Builder注释导致@RequestBody的前端json反序列化失败,HTTP400
  • [ CTF ] WriteUp- 2022年第三届“网鼎杯”网络安全大赛(朱雀组)
  • []sim300 GPRS数据收发程序