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

编译完成后运行结果:

相关推荐
逆向编程9 小时前
如何在Ubuntu虚拟机中使用Vim编辑器?
ubuntu·编辑器·vim
golang学习记10 小时前
VSCode 官宣:全新默认主题!
ide·vscode·编辑器
波尔德10 小时前
vscode codex 字体大小设置
ide·vscode·编辑器
maplewen.10 小时前
【UE】GAS Gameplay Ability
ue5
帅_shuai_14 小时前
UE5.6 Slate独立程序——初始化空白Slate环境
ue5
吴梓穆14 小时前
UE5 c++ 模板函数
java·c++·ue5
吴梓穆15 小时前
UE5 c++ 暴露变量和方法给蓝图
java·c++·ue5
小夭。15 小时前
工具使用-windows在vscode内集成opencode
ide·vscode·编辑器
混迹中的咸鱼15 小时前
UE5 网络联机常用命令
网络·ue5
不才小强16 小时前
VIM从入门指南
编辑器·vim