Files
UnrealLuaDemo/Script/ts/README.md
T

68 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# TypeScript Scripts (`Script/ts`)
本目录是基于 **`ts2lua-unreal`**(TypeScriptToLua + UnLua 定制编译器插件)的 TypeScript 脚本工程,编译产物输出至 `../lua`(即 `Script/lua/`)。
## 目录结构
```text
Script/ts/
├── package.json # 依赖 ts2lua-unreal(Git Tag 锁定)与编译脚本
├── package-lock.json # 锁定精确版本
├── tsconfig.json # 继承 ts2lua-unreal/tsconfig.base.json,outDir -> ../lua
├── types/
│ ├── ue/ # UnLua 自动生成的运行时 UE 反射与蓝图 .d.ts(已裁剪 Editor 模块,请勿手改)
│ └── project.d.ts # 本项目自定义非 UE 全局类型声明
└── src/
├── Framework/ # 纯逻辑基础框架模块(@noSelfInFile)
│ ├── Bootstrap.ts
│ ├── EventBus.ts
│ ├── HotReload.ts
│ └── Log.ts
├── Game/ # UnLua 绑定类(@unlua)
│ ├── LuaGameInstance.ts
│ ├── LuaGameMode.ts
│ ├── LuaPlayerController.ts
│ ├── LuaCharacter.ts
│ └── LuaDemoActor.ts
└── Tests/ # TypeScript -> Lua 5.4 自动化测试套件
├── Harness/ # 轻量级测试运行器与独立 Lua 5.4 UnLua/UE Mock 环境
├── Syntax/ # ts2lua 语法、容器、泛型与 @unlua 继承/静态/解构特性测试
├── UnLuaExamples/ # 参考 UnLua 官方示例 01~09 的 TS 移植与验证
├── Gameplay/ # 常用游戏系统实现(FSM/对象池/定时器/Buff属性/背包/协程/行为树)
├── Extra/ # 框架集成、热重载、Lua 5.4 陷阱与生命周期安全测试
├── UE/ # 真实 UE 5.8 + UnLua 2.3.6 引擎集成测试套件(UERuntimeSuite)
└── RunAllTests.ts # 统一测试入口(支持 lua5.4 独立运行或在 UE 内调用)
```
## 常用命令
```bash
cd Script/ts
# 安装依赖
npm install
# 全量编译到 ../lua
npm run build
# 编译并在本机 Lua 5.4 下运行全部自动化测试(~3s)
npm test
# 编译并在真实 UE 5.8 + UnLua 2.3.6 引擎内无头运行全量测试(-run=RunLuaTests)
npm run test:ue
# 增量监听模式(开发期配合 PIE + UnLua HotReload 使用)
npm run watch
# 查看当前 ts2lua-unreal 版本及本地文档路径
npm run info
```
> 在 UE 编辑器 PIE 运行期间,也可以直接打开控制台输入 `Lua.RunTests` 在当前 PIE `UWorld` 中运行全量测试。
## 规范与文档
- 项目编码约束:[AGENTS.md](../../AGENTS.md)
- 完整语言约束规范:`node_modules/ts2lua-unreal/docs/ts-unlua-spec.md`
- 接入与版本升级指南:`node_modules/ts2lua-unreal/docs/integration-guide.md`