2.9 KiB
2.9 KiB
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
- 相关文章&视频:
- 案例工程:
- 知乎文章:
- UE5 PuerTS学习与实践:https://zhuanlan.zhihu.com/p/632862773
- UE4下基于V8实现的代码热刷新:https://zhuanlan.zhihu.com/p/364505146
- PuerTS:js调用ue的过程:https://zhuanlan.zhihu.com/p/396751427
- UE4:PuerTS的js调试相关:https://zhuanlan.zhihu.com/p/406387721
- 基于Puerts的编辑器UI开发-Mixin的非最佳实践:https://zhuanlan.zhihu.com/p/551338775
TypeScript
- http://www.patrickzhong.com/TypeScript/zh/tutorials/typescript-in-5-minutes.html
- https://ts.xcatliu.com/
- https://jkchao.github.io/typescript-book-chinese/#why
TypeScript Setup
安装:
npm install -g typescript
编译:
tsc xxx.ts
Puerts
QuickStart
- 编译插件后进入工程,点击工具栏的
ue.d.ts
生成接口代码。 - 代码写在项目目录下的
TypeScript
中。(插件运行后会自动创建) - 之后就会在编辑器
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函数。