BlueRoseNote/03-UnrealEngine/Gameplay/PuerTS/Puerts(一)——学习资料归纳.md
BlueRose 4a39ae91cb Merge remote-tracking branch 'origin/master'
# Conflicts:
#	03-UnrealEngine/Gameplay/PuerTS/Puerts(一)——学习资料归纳.md
2023-08-02 11:43:22 +08:00

2.9 KiB
Raw Blame History

title, date, excerpt, tags, rating
title date excerpt tags rating
Puerts——学习资料归纳 2023-07-24 15:12:29 Puerts TypeScript

前言

https://github.com/Tencent/puerts

Puerts

TypeScript

TypeScript Setup

安装:

npm install -g typescript

编译:

tsc xxx.ts

Puerts

QuickStart

  1. 编译插件后进入工程,点击工具栏的ue.d.ts生成接口代码。
  2. 代码写在项目目录下的TypeScript中。(插件运行后会自动创建)
  3. 之后就会在编辑器Blueprints/TypeScript目录下出现资产图标。

调试方法

具体可以参考:# Puerts Inspector指南在UE4和Unity里调试Javascripthttps://zhuanlan.zhihu.com/p/359598262

方式1自创建虚拟机模式下调试配置

创建FJsEnv传入调试端口

//8080是调试端口 GameScript = MakeShared<puerts::FJsEnv>(std::make_unique<puerts::DefaultJSModuleLoader>(TEXT("JavaScript")), std::make_shared<puerts::FDefaultLogger>(), 8080);

阻塞等待调试器链接

GameScript = MakeShared<puerts::FJsEnv>(std::make_unique<puerts::DefaultJSModuleLoader>(TEXT("JavaScript")), std::make_shared<puerts::FDefaultLogger>(), 8080);
GameScript->WaitDebugger();
GameScript->Start("QuickStart", Arguments);

方式2自动绑定模式下调试配置

菜单上选择“编辑->项目设置”,打开设置页面后在“插件->Puerts Setting”页面中开启调试以及设置端口

TypeScript

Puerts

热更新方法

https://zhuanlan.zhihu.com/p/364505146

UE访问Puerts

通过UDynamicDelegateProxy其成员记录了绑定的虚拟机与JS函数。