Dear ImGui的UE5.3集成实践

Dear ImGui一直较为火热,这是一个调试使用并且可以响应快速迭代的Gui库,甚至可以做到在任何代码块中调用API即显示。如果你想更多的了解一下可访问其官方网站:https://www.dearimgui.org/

那么本文就来在UE5中尝试踩坑使用它。

UE4.26版本

网上资料较多的是这个Github上的UE4.26插件版本:
https://github.com/segross/UnrealImGui

先试一下,创建第三人称模板项目,并根据说明加入ImGui依赖:

csharp 复制代码
PublicDependencyModuleNames.AddRange(new string[] { ... , "ImGui" });

在头文件中加入ImGui的include:

cpp 复制代码
#include <imgui.h>

并在移动的代码中插入ImGui语句,以测试:

cpp 复制代码
void AMyProject3Character::MoveForward(float Value)
{
	if ((Controller != nullptr) && (Value != 0.0f))
	{
		// find out which way is forward
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		// get forward vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
		AddMovementInput(Direction, Value);
		ImGui::Text("Hello, world %f", Value);
	}
}

所见即所得,若没有数值则不会绘制GUI:

UE5.3

但是这款4.26版本的插件移植到UE5并不方便,于是我找到了github上另一个UE5.0.1的插件版本:
https://github.com/stungeye/UE5-With-Dear-ImGui

直接拿工程重新编译,有些地方需要修改,具体修改内容也不一定都正确,就不写了,至少改改能用。

Demo中将ImGui的测试脚本写在了ImGuiActor中,只需要在新场景拖入该Actor即可。

编译完成后运行结果:

相关推荐
山顶望月川1 小时前
并行科技MaaS平台支持文心4.5系列开源模型调用
人工智能·机器学习·编辑器
GDAL2 小时前
Node.js REPL 教程
node.js·编辑器·vim
向宇it3 小时前
【unity游戏开发——网络】网络游戏通信方案——强联网游戏(Socket长连接)、 弱联网游戏(HTTP短连接)
网络·http·游戏·unity·c#·编辑器·游戏引擎
ue星空5 小时前
UE5音频技术
ue5
切韵10 天前
Unity编辑器扩展:UI绑定复制工具
ui·unity·编辑器
F_D_Z10 天前
【vim】通过vim编辑器打开、修改、退出配置文件
linux·编辑器·vim
:-)10 天前
VSCode新窗口背景水印logo修改美化
ide·vscode·编辑器
Tianzs_10 天前
编辑器及脚本案例
linux·服务器·编辑器
帅_shuai_11 天前
UE5 游戏模板 —— FirstShootGame
游戏·ue5
黑塞12311 天前
Vscode 编写Markdown支持 plantuml书写
ide·vscode·编辑器·markdown·plantuml