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

编译完成后运行结果:

相关推荐
山峰哥7 天前
吃透 SQL 优化:告别慢查询,解锁数据库高性能
服务器·数据库·sql·oracle·性能优化·编辑器
holeer7 天前
【V1.0】Typora 中的 HTML 支持|软件文档自翻译
前端·编辑器·html·typora·web·markdown·文档
硬汉嵌入式7 天前
Vim 9.2版本正式发布
编辑器·vim
zhangzhangkeji7 天前
UE5 C++(71):文件是否存在,文件夹是否存在,FPaths :: FileExists( const FString & InPath) ;
ue5
吹牛不交税7 天前
关于vscode左侧资源管理器目录层级疑似异常的问题
ide·vscode·编辑器
妙为7 天前
UE5角色穿过石头穿模
ue5·unreal engine5·角色穿越石头·穿模
No8g攻城狮7 天前
【Linux】Linux nano 编辑器全攻略:从入门到精通
linux·运维·编辑器·nano
你怎么知道我是队长8 天前
VsCode插件推荐---Todo Tree
ide·vscode·编辑器
becatjd8 天前
VScode的claude code插件报错command ‘claude-vscode.editor.openLast‘ not found
ide·vscode·编辑器·claude·anthropic·claude code
BIBI20498 天前
下载指定历史版本 VSCode 或 VSCode Insider
ide·vscode·编辑器