A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
docs: the Script Graph guide corrected against the real editor, and a Device Disk Cache page
yhhe41a1960a6e8
diff --git a/docs/astro/astro.config.mjs b/docs/astro/astro.config.mjsindex cb5e9adad..9f851ca0e 100644--- a/docs/astro/astro.config.mjs+++ b/docs/astro/astro.config.mjs@@ -316,6 +316,7 @@ export default defineConfig({{ label: 'WeChat MiniGame', translations: { 'zh-CN': '微信小游戏' }, slug: 'publishing/wechat' },{ label: 'Mini-Game Platforms', translations: { 'zh-CN': '小游戏平台' }, slug: 'publishing/minigame-platforms' },{ label: 'Hot Update', translations: { 'zh-CN': '热更新' }, slug: 'publishing/hot-update' },+ { label: 'Device Disk Cache', translations: { 'zh-CN': '设备磁盘缓存' }, slug: 'publishing/content-cache' },{ label: 'Ads & Sharing', translations: { 'zh-CN': '广告与分享' }, slug: 'publishing/ads-sharing' },],},diff --git a/docs/astro/src/content/docs/gameplay/script-graphs.mdx b/docs/astro/src/content/docs/gameplay/script-graphs.mdxindex 3eb6a8af2..41a82c3e1 100644--- a/docs/astro/src/content/docs/gameplay/script-graphs.mdx+++ b/docs/astro/src/content/docs/gameplay/script-graphs.mdx@@ -44,7 +44,7 @@ activation evaluates it again, which is what lets a **While** condition become f## Adding nodesThe **Node** button in the toolbar (or right-click on the canvas) lists nodes in-groups:+groups (**Events**, **Flow**, **Variables**, **Values**, **Actions**, **Queries**, **Graphs**):| Group | Nodes ||---|---|@@ -52,8 +52,13 @@ groups:| **Flow** | **Branch**, **Sequence** (configurable pin count), **While**, **Delay**. || **Variables** | **Get variable**, **Set variable**. || **Values** | **Number**, **Boolean**, **String** literals. |-| **Queries** | Value-only nodes (no exec pin): arithmetic (Add, Subtract, Multiply, Divide, Absolute, Clamp, Random), comparisons (Less than, Greater than), **And**, **Join strings**, **Key pressed**, **Input axis**, **Find entity by name**, **Get property**, plus every registered **condition**. |-| **Actions** | Nodes with an exec pin that do something: **Spawn entity**, **Destroy entity**, **Set property**, **Call graph**, plus every action you registered in code. |+| **Actions** | Nodes with an exec pin that do something: `timeline.play` / `timeline.pause`, `spriteAnim.play` / `restart` / `stop`, `audio.play` / `stop`, `soundEvent.trigger` / `stop`, `property.set`, `entity.despawn`, `debug.log`, `scene.load` / `reload`, `ui.setVisible`, `ui.setPage`, `fsm.fire`, `blackboard.set` — plus every action you register in code. |+| **Queries** | Value-only nodes (no exec pin): `math.*` (add, subtract, multiply, divide, min, max, abs, clamp, lerp, random), `compare.*` (equal, less, greater), `logic.*` (and, or, not), `string.concat`, `property.get`, `entity.self`, `entity.byName`, `input.down` / `pressed` / `axis` / `pointer` — plus every registered condition. |+| **Graphs** | Every other callable graph in the project, to call it with a **Call graph** node (empty until a graph declares an input). |++The menu lists the verbs by their registry name; once placed, a node is titled+readably (**Find entity by name**, **Key pressed**, **Set property**…) with the name+underneath.An action or condition you register with `registerAction` / `registerCondition` — thesame ones state machines and behavior trees use — appears here with the ports its@@ -65,21 +70,22 @@ editor-only and ignored at runtime.## Variables-The **Variables** panel on the canvas lists the graph's **Variables**, **Inputs** and-**Outputs**, searchable, with how often each is read and written (or *unused*).+The panel beside the canvas has three sections — **Inputs**, **Outputs** and+**Variables** — each with a count and an **Add** button, searchable, showing how often+each entry is read and written (or *unused*).-- **+ Variable** declares a typed variable with a default. It is **declared by the+- **Add** under **Variables** declares a typed variable with a default. It is **declared by theasset but valued per entity** — two entities running the same graph each keep theirown.-- **Drag** a variable onto the canvas to read it, or choose **Get / Set** from the- right-click menu.+- **Drag** a variable onto the canvas: a plain drop asks **Get** or **Set**; hold `Ctrl/⌘`+ to drop a Get, `Alt` to drop a Set, with no question.- Rename or change a variable's type from its row. Deleting one that nodes still useleaves those nodes on the canvas, without a variable, and asks first.## Callable graphs-A graph becomes **callable** when you declare **+ In** (an input pin) or **+ Out** (an-output pin) on it. Another graph then runs it with a **Call graph** node, handing+A graph becomes **callable** when you **Add** an entry under **Inputs** (an input pin)+or **Outputs** (an output pin). Another graph then runs it with a **Call graph** node, handingvalues in and reading results back — the signature lives on the callee, so changing itredraws every caller.diff --git a/docs/astro/src/content/docs/publishing/content-cache.mdx b/docs/astro/src/content/docs/publishing/content-cache.mdxnew file mode 100644index 000000000..8c053be00--- /dev/null+++ b/docs/astro/src/content/docs/publishing/content-cache.mdx@@ -0,0 +1,79 @@+---+title: Device Disk Cache+description: What a hot-updated game keeps on the device's disk, which versions are protected, and how to inspect, budget and clean that cache from the editor's Profiler.+---++A game that loads [Remote content](/docs/publishing/hot-update/) writes the verified+bytes to a **disk cache** on the device, so updated assets load without the network on+the next launch. Left alone that cache only grows: every update leaves the previous+revision's files behind. The Profiler's **Device disk cache** section shows what is+stored, what is safe to remove, and cleans it down to a budget — without ever deleting+a revision the game may still need.++## Where the cache exists++| Target | Disk cache |+| --- | --- |+| **Desktop** | Managed — it can be listed, measured and cleaned. |+| **Mini-games**, **Native (iOS / Android)** | Managed when the host's file API can list and delete files; otherwise storage only (below). |+| **Web** | None. The next launch refetches from the CDN. |++The section reports which of three states the connected host is in:++- **Managed** — the full controls below.+- **Storage only** — the host stores cache bytes but cannot list or safely delete+ them, so usage is not available.+- **Unavailable** — the platform has no managed disk cache.++## Opening it++Connect a device (see [Hot update](/docs/publishing/hot-update/)), open the+**Profiler**, and set **Profiler source** to **Device**. The **Device disk cache**+section appears under the device's controls. It reads once when you pick the device;+a directory scan is too expensive to poll, so use **Rescan** to refresh it.++## What it shows++One summary line:++> Resources *used* · protected *protected* · reclaimable *free* · index *index*++- **Resources** — bytes of cached assets on disk.+- **Protected** — bytes the game may still need: files that belong to a protected+ version, plus files whose owner is unknown.+- **Reclaimable** — everything else; the only bytes a cleanup can free.+- **Index** — the cache's own bookkeeping file, counted separately.++Below it, one row per **version** the cache knows, with its revision, why it is kept+and how many of its files are **missing** from disk:++| Label | Meaning |+| --- | --- |+| **Current** | The revision the game is running on. |+| **Pending** | An update that was found and staged, not yet committed. |+| **Rollback** | The previous revision, kept so a failed update can fall back. |+| **Next launch / Retained** | A revision you chose to keep. |+| **Old version** | Nothing protects it — its files are reclaimable. |++Files with unknown ownership (from before the cache tracked them) are protected until+a verified write establishes what they are, and saves are always excluded from cleanup.++## Keeping a version++On the running build's own versions, **Keep version** reserves a revision — say the+build QA is testing — so advancing the current/rollback pair cannot release it.+**Release reservation** gives it back. Retention is stored apart from the automatic+protection, so an update never silently drops a revision you kept.++## Cleaning to a budget++1. Set **Resource budget** in MiB (default 128).+2. **Preview cleanup** — shows how many files would be released and how many bytes,+ deleting nothing.+3. **Clean unprotected resources** — deletes them, least recently used first, until the+ cache fits the budget, and reports the bytes released and any deletions that failed.++Only unprotected files are ever candidates. If the protected files alone exceed the+budget the panel says so and keeps them — the budget is a target, never a reason to+delete a version the game needs. If the cleanup freed space but could not store the+updated index, it says so; the next scan reconciles it.diff --git a/docs/astro/src/content/docs/zh-cn/gameplay/script-graphs.mdx b/docs/astro/src/content/docs/zh-cn/gameplay/script-graphs.mdxindex b33f8d3a4..f9e38f0b8 100644--- a/docs/astro/src/content/docs/zh-cn/gameplay/script-graphs.mdx+++ b/docs/astro/src/content/docs/zh-cn/gameplay/script-graphs.mdx@@ -33,7 +33,7 @@ description: 用节点和连线可视化编写玩法逻辑,保存为 .esgraph## 添加节点-工具栏的**节点**按钮(或在画布上右键)按组列出节点:+工具栏的**节点**按钮(或在画布上右键)按组列出节点(**事件**、**流程**、**变量**、**常量**、**动作**、**取值**、**图**):| 分组 | 节点 ||---|---|@@ -41,8 +41,11 @@ description: 用节点和连线可视化编写玩法逻辑,保存为 .esgraph| **流程** | **分支**、**顺序**(引脚数可配)、**循环**、**延迟**。 || **变量** | **读取变量**、**设置变量**。 || **常量** | **数字**、**布尔**、**字符串**字面量。 |-| **取值** | 只产出值的节点(没有执行引脚):算术(加、减、乘、除、绝对值、限制范围、随机数)、比较(小于、大于)、**与**、**拼接字符串**、**按键按下**、**输入轴**、**按名称找实体**、**读取属性**,以及所有已注册的**条件**。 |-| **动作** | 带执行引脚、会做事的节点:**生成实体**、**销毁实体**、**设置属性**、**调用图**,以及你在代码里注册的所有动作。 |+| **动作** | 带执行引脚、会做事的节点:`timeline.play` / `timeline.pause`、`spriteAnim.play` / `restart` / `stop`、`audio.play` / `stop`、`soundEvent.trigger` / `stop`、`property.set`、`entity.despawn`、`debug.log`、`scene.load` / `reload`、`ui.setVisible`、`ui.setPage`、`fsm.fire`、`blackboard.set`——以及你在代码里注册的所有动作。 |+| **取值** | 只产出值的节点(没有执行引脚):`math.*`(add、subtract、multiply、divide、min、max、abs、clamp、lerp、random)、`compare.*`(equal、less、greater)、`logic.*`(and、or、not)、`string.concat`、`property.get`、`entity.self`、`entity.byName`、`input.down` / `pressed` / `axis` / `pointer`——以及所有已注册的条件。 |+| **图** | 项目里其他可调用的图,用**调用图**节点来调用(在有图声明了入参之前为空)。 |++菜单按注册名列出这些动词;放到画布上之后,节点会用易读的标题(**按名称找实体**、**按键按下**、**设置属性**……),下面附上注册名。你用 `registerAction` / `registerCondition` 注册的动作和条件——状态机、行为树用的是同一批——会按它们的声明带着对应端口出现在这里。文件里只存动词的*名字*,所以旧图会按当前的声明重新绘制,不会保留动词早已没有的端口。@@ -51,15 +54,16 @@ description: 用节点和连线可视化编写玩法逻辑,保存为 .esgraph## 变量-画布上的**变量面板**列出图的**变量**、**入参**和**出参**,可搜索,并显示每一项被读、被写的次数(或*未使用*)。+画布旁的面板有三个区——**入参**、**出参**和**变量**——各带数量和一个**添加**按钮,可搜索,+并显示每一项被读、被写的次数(或*未使用*)。-- **+ 变量**声明一个带默认值的有类型变量。它**由资产声明、按实体取值**——两个运行同一张图的实体各自有自己的值。-- 把变量**拖**到画布上即可读取,也可在右键菜单里选**读取 / 设置**。+- **变量**区的**添加**声明一个带默认值的有类型变量。它**由资产声明、按实体取值**——两个运行同一张图的实体各自有自己的值。+- 把变量**拖**到画布上:直接松手会询问**读取**还是**设置**;按住 `Ctrl/⌘` 直接放读取节点,按住 `Alt` 直接放设置节点,不再询问。- 在变量那一行可以改名或更改类型。删除一个仍被节点使用的变量时会先确认;那些节点留在画布上,只是失去变量。## 可调用的图-给一张图声明 **+ 入参**(输入引脚)或 **+ 出参**(输出引脚),它就变成**可调用**的。+在**入参**区(输入引脚)或**出参**区(输出引脚)**添加**条目,这张图就变成**可调用**的。别的图用**调用图**节点运行它,传值进去、读回结果——签名在被调用方身上,改了签名,所有调用方都会跟着重绘。一次调用会在调用方的这一步里**同步运行到结束**。每个调用点为被调用图保留自己的帧,被调用图消耗的是调用方的步数预算,diff --git a/docs/astro/src/content/docs/zh-cn/publishing/content-cache.mdx b/docs/astro/src/content/docs/zh-cn/publishing/content-cache.mdxnew file mode 100644index 000000000..04f21aed3--- /dev/null+++ b/docs/astro/src/content/docs/zh-cn/publishing/content-cache.mdx@@ -0,0 +1,65 @@+---+title: 设备磁盘缓存+description: 热更新的游戏会在设备磁盘上留下什么、哪些版本受保护,以及如何在编辑器的性能分析器里查看、设预算并清理这份缓存。+---++加载[远程内容](/docs/zh-cn/publishing/hot-update/)的游戏会把校验过的字节写进设备上的**磁盘缓存**,+这样更新后的资源下次启动时无需联网就能加载。放着不管的话,缓存只会越来越大:每次更新都会把上一版的文件留下。+性能分析器里的**设备磁盘缓存**一节会显示存了什么、哪些可以安全删除,并把缓存清理到预算以内——+而且绝不会删掉游戏可能还需要的版本。++## 哪些平台有缓存++| 目标 | 磁盘缓存 |+| --- | --- |+| **桌面** | 受管理——可以列出、统计和清理。 |+| **小游戏**、**原生(iOS / Android)** | 宿主的文件接口能列出并删除文件时受管理;否则为仅存储(见下)。 |+| **Web** | 没有。下次启动从 CDN 重新拉取。 |++这一节会告诉你连接的宿主处于三种状态里的哪一种:++- **受管理**——下面全部控件可用。+- **仅存储**——宿主能存缓存字节,但不能列出或安全删除,所以看不到用量。+- **不可用**——该平台没有受管理的磁盘缓存。++## 打开它++连接设备(见[热更新](/docs/zh-cn/publishing/hot-update/)),打开**性能分析器**,把**性能分析源**设为**设备**。+**设备磁盘缓存**一节出现在设备控件下方。选中设备时读取一次;目录扫描太贵,不会轮询,需要刷新就点**重新扫描**。++## 它显示什么++一行汇总:++> 资源 *已用* · 受保护 *受保护* · 可释放 *可释放* · 索引 *索引*++- **资源**——磁盘上缓存的资产字节数。+- **受保护**——游戏可能还要用的字节:属于受保护版本的文件,加上归属未知的文件。+- **可释放**——其余所有;清理只能释放这部分。+- **索引**——缓存自己的记账文件,单独统计。++下面是缓存认识的每个**版本**一行,给出修订号、保留的原因,以及它有多少文件在磁盘上**缺失**:++| 标签 | 含义 |+| --- | --- |+| **当前版本** | 游戏正在运行的修订。 |+| **待提交** | 已发现并暂存、但还没提交的更新。 |+| **回退版本** | 上一个修订,留着让失败的更新能退回。 |+| **下次启动 / 保留版本** | 你主动保留的修订。 |+| **旧版本** | 没有任何东西保护它——它的文件可释放。 |++归属未知的文件(缓存开始追踪之前就有的)会受保护,直到一次校验过的写入确认它们是什么;存档永远不参与清理。++## 保留一个版本++对运行中构建自己的版本,**保留版本**会预留一个修订——比如 QA 正在测的那个构建——这样当前 / 回滚这一对前进时不会把它释放。+**取消额外保留**把它还回去。保留与自动保护分开存放,所以更新不会悄悄丢掉你保留的修订。++## 按预算清理++1. 设**资源预算**,单位 MiB(默认 128)。+2. **预览清理**——显示会释放多少文件、多少字节,不删除任何东西。+3. **清理未保护资源**——按最近最少使用的顺序删除,直到缓存符合预算,并报告释放的字节数和删除失败的数量。++只有未受保护的文件才会成为候选。如果受保护文件本身就超过预算,面板会说明并保留它们——+预算是目标,从来不是删除游戏所需版本的理由。如果清理释放了空间但没能存下更新后的索引,面板会说明;下次扫描会对齐它。