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即可。

编译完成后运行结果:

相关推荐
on_pluto_12 小时前
【debug】vscode 和 codex 不兼容问题
ide·人工智能·vscode·编辑器
Web - Anonymous16 小时前
Vue3 + Element Plus 集成 JSON Editor 实现实时校验 JSON 编辑器(高亮/暗亮主题/分栏回显/组件复用) - 附完整示例
vue.js·编辑器·json
1204157137 肖哥17 小时前
UE5.7 灯光详解
ue5
迷路爸爸1802 天前
cursor资源管理器修改为与vscode一样的纵向布局
ide·vscode·编辑器
TO_ZRG2 天前
Unity 编辑器之 EditorTool、EditorToolBar、Overlay属性
编辑器
星羽XingYu2 天前
esp32 vscode clangd 无法索引库函数解决方案
ide·vscode·编辑器
北漂燕郊杨哥2 天前
DotMD:一款基于 Go + Wails 的轻量开源 Markdown 桌面编辑器
golang·开源·编辑器·markdown·md
狂云歌2 天前
AI写UE的3Dgame
人工智能·3d·ue5·游戏程序
末代iOS程序员华仔2 天前
Cursor 编辑器 + Figma‑MCP 服务器(真正让 Codex 直接读取 Figma 链接,高级方案)
服务器·编辑器·figma
平头某2 天前
DSH:Agent 的 VSCode 时刻?
ide·vscode·编辑器