使用VsCode调试UE5的PuerTs - 1EON
source link: https://www.cnblogs.com/1eon/p/16851750.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
使用VsCode调试UE5的PuerTs
1、下载测试的Demo项目
配置PuerTs的步骤这里不赘述。
2、准备工作
2.1 打开项目
正常来说,直接打开项目可以看到如下画面
如果直接点击运行,可以发现下方的 Output Log 窗口已经开始 Print 了很多案例。
是因为该项目默认执行的是QuickStart.ts。
2.2 打开TsGameInstance.cpp
3、添加VsCode断点
3.1 在VsCode找到QuickStart.ts,随便断一个点
(这里我们以 L17 为例)
4、 修改虚拟机端口 (8889)
(如果不知虚拟机的用途,可以查看ZombieYang大佬的推文)
回到TsGameInstance.cpp中
将 注释的代码 取消注释
图片过长,目前代码如下:
void UTsGameInstance::OnStart()
{
//GameScript = MakeShared<puerts::FJsEnv>();
GameScript = MakeShared<puerts::FJsEnv>(std::make_unique<puerts::DefaultJSModuleLoader>(TEXT("JavaScript")), std::make_shared<puerts::FDefaultLogger>(), 8889);
GameScript->WaitDebugger();
TArray<TPair<FString, UObject*>> Arguments;
Arguments.Add(TPair<FString, UObject*>(TEXT("GameInstance"), this));
GameScript->Start("QuickStart", Arguments);
}
注意看修改后的代码。我这里已经将端口更改为 " 8889 "
同时打开了WaitDebugger(),目的是Client等待V8的虚拟机(Client和V8虚拟机的关系同样可以查看ZombieYang大佬的推文)
5、添加VsCode配置
5.1 打开VsCode的Debug配置
5.2 选择 Node.js : Attach
5.3 更改端口为 (8889)
6、开始Debug
6.1 启动VsCode待命
①首先选择5.2添加的Debug配置
②点击左侧绿色 三角形
可以看到如下示意框
6.2 启动2.1的项目
不出意外已经成功被中断。
7、 尽情Debug~
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK