[✔️]unreal插件lua-profiler:分析lua性能

527 阅读1分钟

我使用的unreal engine version : 4.27.2

当我尝试将lua-profiler放到unreal项目中后,提示:

image.png image.png

Tencent-UnLua

将Plugins目录下的插件放到自己项目的Plugins下:

image.png

这是因为使用的unreal版本不相同导致的,GitHub上UnLua使用的是4.26

image.png

image.png

注意你的磁盘剩余空间,编译失败也有这方面的原因

编译成功后,会在插件的Binaries目录下生成dll文件

ELuaProfiler插件的窗口位置:

窗口/ELuaProfiler/ELuaMonitor

新建一个class类

image.png

image.png

image.png

添加完之后会经历漫长的c++编译过程,最终你会在内容浏览器中找到这个资源

image.png

将这个character拖拽到场景中,这样character关联的c++代码才能运行: image.png

尝试着输出hello world:

打开关联的c++代码,点击后会自动打开vs,并打开对应的代码: image.png

修改MyCharacter.cpp:

// Fill out your copyright notice in the Description page of Project Settings.
#include "MyCharacter.h"
#include "Engine/Engine.h" // 引入头文件
// Sets default values
AMyCharacter::AMyCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void AMyCharacter::BeginPlay()
{
	Super::BeginPlay();
	// 在游戏运行窗口显示一个文字
	GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::White, TEXT("Hello World"));
}

// Called every frame
void AMyCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

// Called to bind functionality to input
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);
}

回到unreal editor中执行编译

image.png

image.png

编译完毕后,执行运行,在游戏窗口左上角就看到了log:

image.png

编译报错UnLua.h no such file or directory

暂时不清楚为什么找不到,我手动把这2个目录加入进去就好了

\Plugins\UnLua\Source\ThirdParty\Lua\lua-5.4.3\src
\Plugins\UnLua\Source\UnLua\Public

image.png