--- title: Puerts(一)——学习资料归纳 date: 2023-07-24 15:12:29 excerpt: tags: Puerts TypeScript rating: ⭐ --- # 前言 https://github.com/Tencent/puerts - [安装方法](https://github.com/Tencent/puerts/blob/master/doc/unreal/zhcn/install.md) - [FAQ](https://github.com/Tencent/puerts/blob/master/doc/unreal/zhcn/faq.md) - [更新日志](https://github.com/Tencent/puerts/blob/master/doc/unreal/zhcn/changelog.md) ## Puerts - 相关文章&视频: - [UE引擎里头跑个nodejs服务器是怎样一种体验?](https://zhuanlan.zhihu.com/p/428250631) - [在你的ios、android应用中嵌入官方版nodejs是什么感觉?](https://zhuanlan.zhihu.com/p/568969543) - [[UnrealCircle深圳] puerts-UE下TypeScript编程插件 | 腾讯 车雄生](https://www.bilibili.com/video/BV1oB4y1A7dY/?spm_id_from=333.337.search-card.all.click&vd_source=d47c0bb42f9c72fd7d74562185cee290) - 案例工程: - https://github.com/chexiongsheng/puerts_unreal_demo - 知乎文章: - 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 安装: ```bash npm install -g typescript ``` 编译: ```bash 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传入调试端口 ```c++ //8080是调试端口 GameScript = MakeShared(std::make_unique(TEXT("JavaScript")), std::make_shared(), 8080); ``` 阻塞等待调试器链接 ```c++ GameScript = MakeShared(std::make_unique(TEXT("JavaScript")), std::make_shared(), 8080); GameScript->WaitDebugger(); GameScript->Start("QuickStart", Arguments); ``` #### 方式2:自动绑定模式下调试配置 菜单上选择“编辑->项目设置”,打开设置页面后在“插件->Puerts Setting”页面中开启调试以及设置端口 # TypeScript # Puerts ## 热更新方法 https://zhuanlan.zhihu.com/p/364505146 ## UE访问Puerts 通过UDynamicDelegateProxy,其成员记录了绑定的虚拟机与JS函数。