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

编译完成后运行结果:

相关推荐
艾斯比的日常8 小时前
VSCode 实用快捷键
ide·vscode·编辑器
Galaxy_12298 小时前
vscode远程报错:Remote host key has changed,...
ide·vscode·编辑器
瞌睡不来19 小时前
(学习总结25)Linux工具:vim 编辑器 和 gcc/g++ 编译器
linux·学习·编辑器·vim·编译器·gcc/g++
爱写代码的山山1 天前
虚幻蓝图解决抗锯齿方案
游戏·ue5·游戏引擎·虚幻·抗锯齿化
Deveuper1 天前
UE5 Niagara 粒子远处闪烁解决
ue5
▍ 小太阳 ☼1 天前
UE5打组后GroupActor重命名不了
ue5
Aphelios3801 天前
Linux 下 VIM 编辑器学习记录:从基础到进阶(上)
java·linux·编辑器·vim
workflower2 天前
实例研究:设计一个文档编辑器(24)- 完
java·开发语言·设计模式·编辑器·软件工程·需求分析·软件需求
咩咩大主教2 天前
VSCode运行Go程序报错:Unable to process `evaluate`: debuggee is running
开发语言·ide·vscode·golang·编辑器
快下雨了L2 天前
UE5TSubclassOf模板,定时器的使用,SpawnActor函数的使用,SetStaticMesh函数的使用
ue5