[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7FBNN4WFN0PHM6P7SDH7V0J":3,"skill-same:01M7FBNN4WFN0PHM6P7SDH7V0J":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7FBNN4WFN0PHM6P7SDH7V0J","godot-scene-architecture",null,"拆分 Godot 4 场景与组织节点时用。PackedScene 组件复用、节点引用 @onready @export %UniqueName、信号与直接调用的选择、分组 call_group、Autoload 与普通节点、组合与继承、状态机、暂停 process_mode、queue_free 与 is_instance_valid、_ready 顺序、场景切换。scene tree architecture, signals, autoload.","MindsMaster\u002Fgodot-claude-code-skills","MindsMaster","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167383411?v=4","01M7FBJFZBSAXET9TF9WDFRCJW","An5w1r","01M7FBJFZZRARX0F1VSWHTH9EM",3,"MIT","https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-architecture\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: godot-scene-architecture\ndescription: 拆分 Godot 4 场景与组织节点时用。PackedScene 组件复用、节点引用 @onready @export %UniqueName、信号与直接调用的选择、分组 call_group、Autoload 与普通节点、组合与继承、状态机、暂停 process_mode、queue_free 与 is_instance_valid、_ready 顺序、场景切换。scene tree architecture, signals, autoload.\n---\n\n# Godot 场景架构\n\n场景拆分、节点引用、节点通信、状态机、暂停与场景切换的约定。\n\n默认结构：一个概念一个 `.tscn`，脚本挂在场景根，对外只露 `@export` 属性、信号和少量方法。\n\n## 范围\n\n| 不含 | 去哪 |\n|---|---|\n| 内容摆进 `.tscn` 还是代码生成、脚本生成场景文件 | godot-scene-authoring |\n| 具体节点用法 | godot-2d godot-3d godot-ui godot-animation |\n| `Resource` 当数据、存档 | godot-resources-data |\n| `@tool` 与编辑器插件 | godot-editor-tooling |\n| C# 信号、导出、生命周期写法 | godot-csharp |\n| 失焦自动暂停、设置界面 | godot-ui |\n| 屏幕外停用、大量实体 | godot-performance |\n| 收尾音效、同时多声 | godot-audio |\n\n## 先查内置\n\n| 需求 | 用这个 | 别自己写 |\n|---|---|---|\n| 可复用对象 敌人 子弹 面板 | 独立 `.tscn` + `PackedScene.instantiate()` | 代码 `new` 整棵节点树 |\n| 同场景内的节点引用 | `%UniqueName` 或 `@onready` 缓存 | 长路径 `get_node(\"A\u002FB\u002FC\")`，每帧 `get_node` |\n| 场景外的目标引用 | `@export var target: Node2D` | 写死 `\u002Froot\u002FMain\u002FLevel\u002FPlayer` |\n| 一类对象批量通知 | `add_to_group` + `get_tree().call_group` | 手写注册表数组，全局事件总线 |\n| 子对象通知父对象 | 信号 | 子节点 `get_parent().foo()` |\n| 全局共享数据 | 自定义 `Resource`，或 autoload 只放全局状态 | Manager 套 Manager |\n| 状态切换 | `enum` + `match`、状态子节点、`AnimationTree` | 一串 `is_jumping` `is_attacking` bool |\n| 暂停菜单 | `SceneTree.paused` + `Node.process_mode` | 每个脚本判断 `is_paused` |\n| 多个场景共用逻辑 | `class_name` 组件节点 | 复制粘贴，深继承链 |\n| 场景切换 | `change_scene_to_file`、`change_scene_to_packed` | 手动 `free` 旧场景再 `add_child` |\n| 非节点的纯逻辑对象 | `RefCounted` 或 `Resource` | 继承 `Node` 只为存数据 |\n\n## 做法\n\n### 实例化\n\n```gdscript\nclass_name Bullet\nextends Area2D\n\nvar direction: Vector2 = Vector2.RIGHT\nvar speed: float = 400.0\n\nfunc _physics_process(delta: float) -> void:\n\tposition += direction * speed * delta\n```\n\n```gdscript\nclass_name Spawner\nextends Node2D\n\n@export var bullet_scene: PackedScene\n\nfunc fire(dir: Vector2) -> void:\n\tvar bullet := bullet_scene.instantiate() as Bullet\n\tbullet.direction = dir\n\tget_parent().add_child(bullet)\n\tbullet.global_position = global_position\n```\n\n- 初始参数在 `add_child` 前设，`_ready` 里可读\n- `global_position` 在 `add_child` 后设\n- `add_child` 前设 `global_position`：2D 按本地坐标算，3D 报错\n- 场景引用用 `@export var scene: PackedScene`，文件移动后引用不断\n- 同脚本内固定不变的小场景可用 `preload`\n- 代码生成节点并存进 `PackedScene` 时，每个节点设 `owner`，见 [references\u002Flifecycle.md](references\u002Flifecycle.md)\n\n### 节点引用\n\n```gdscript\nextends Node2D\n\n@export var target: Node2D\n@export_node_path(\"Marker2D\") var spawn_path: NodePath\n\n@onready var score: Label = %ScoreLabel\n@onready var sprite: Sprite2D = $Sprite2D\n@onready var spawn: Marker2D = get_node(spawn_path)\n\nfunc _process(_delta: float) -> void:\n\tif target != null:\n\t\tlook_at(target.global_position)\n```\n\n| 写法 | 用于 |\n|---|---|\n| `$Name` | 直接子节点 |\n| `%Name` | 同场景更深的节点，先在场景面板右键 `Access as Unique Name` |\n| `@export var x: Node2D` | 场景外的目标，Inspector 里连 |\n| `get_node_or_null` | 节点可能不存在 |\n\n- 引用用 `@onready` 缓存为带类型成员，不在 `_process` 里取\n- `@export` 节点引用在 `instantiate()` 返回时已解析\n- `@export` 节点引用在 `_enter_tree` 和 `_ready` 可用，`_init` 里是 `null`\n- 代码 `instantiate()` 的场景，场景外的引用由调用方赋值\n\n### 通信\n\n原则 call down, signal up。\n\n| 方向 | 做法 |\n|---|---|\n| 父到子 | 直接调方法或设属性 |\n| 子到父 | 子 `emit` 信号，父 `connect` |\n| 兄弟之间 | 经共同父节点转发，或各自 `@export` 对方 |\n| 子需要父提供的行为 | 父把方法赋给子的 `Callable` 属性 |\n\n```gdscript\nclass_name Health\nextends Node\n\nsignal changed(current: int, maximum: int)\nsignal died\n\n@export var maximum: int = 100\n\n@onready var current: int = maximum\n\nfunc damage(amount: int) -> void:\n\tcurrent = maxi(current - amount, 0)\n\tchanged.emit(current, maximum)\n\tif current == 0:\n\t\tdied.emit()\n```\n\n```gdscript\nextends CharacterBody2D\n\n@onready var health: Health = $Health\n\nfunc _ready() -> void:\n\thealth.died.connect(queue_free)\n```\n\n- 信号名用过去式：`died` `item_collected`\n- 信号只报告已发生的事，要对方做事就调方法\n- 成员初始化器读 `@export` 得到脚本默认值\n- 依赖 Inspector 所设值的初值用 `@onready`\n- 编辑器 Node 面板连的信号存在 `.tscn`，改方法名无提示。优先脚本里 `connect`\n\n### 分组\n\n```gdscript\nextends Node2D\n\nfunc raise_alarm() -> void:\n\tget_tree().call_group(\"guards\", \"alert\", global_position)\n```\n\n- 分组用作一类对象的广播通道，不当全局注册表\n- 加入分组：节点面板 Groups 页签，或 `add_to_group(\"guards\")`\n- `call_group_flags(SceneTree.GROUP_CALL_DEFERRED, ...)` 帧末执行，遍历中会增删节点时用\n- 场景唯一对象用 `get_first_node_in_group(\"player\")`，`_ready` 里取一次并缓存\n\n### Autoload\n\n用于跨场景存活的全局状态：存档槽、设置、场景切换器、跨关卡任务进度。`change_scene_to_*` 不释放 autoload。\n\n```ini\n[autoload]\n\nSettings=\"*res:\u002F\u002Fsrc\u002Fautoload\u002Fsettings.gd\"\n```\n\n- 能放进场景的就放进场景\n- 不做全局音效池，场景自带 `AudioStreamPlayer`\n- `*` 对应面板 Enable 列，开启后 GDScript 才有全局名\n- C# 不读 `*`，自己写静态 Instance 属性\n- autoload 的 `_ready` 早于主场景加载，取不到场景节点\n- 共享函数用 `class_name` + `static func`，不需要 autoload\n- 共享数据用自定义 `Resource`，不需要 autoload\n- 不建 GameManager、EventBus、UIManager\n- 不建信号总线，收发方无法追踪\n\n### 组合与继承\n\n```gdscript\nclass_name HurtBox\nextends Area2D\n\n@export var health: Health\n\nfunc _ready() -> void:\n\tarea_entered.connect(_on_area_entered)\n\nfunc _on_area_entered(area: Area2D) -> void:\n\tif area is HitBox:\n\t\thealth.damage(area.damage)\n```\n\n```gdscript\nclass_name HitBox\nextends Area2D\n\n@export var damage: int = 1\n```\n\n| 手段 | 用于 | 限制 |\n|---|---|---|\n| 组件子节点 | 多种对象共有的行为，如 `Health` `HurtBox`，不建 Damageable 基类 | 宿主用 `@export` 传入，不用 `get_parent()` |\n| 脚本继承 | 同类事物的细分 | 一层，要第三层先拆组件 |\n| 继承场景 | 同一模板的变体，如换贴图和数值的敌人 | 父场景改结构影响所有变体 |\n| `Editable Children` | 改子场景内部节点 | 改动存在宿主场景，父场景改结构后易失效 |\n\n### 状态机\n\n| 状态数与转移 | 用法 |\n|---|---|\n| 2 到 5 个，转移简单 | `enum State` + `match`，见 [references\u002Fenum-state.md](references\u002Fenum-state.md) |\n| 每个状态有进出逻辑和数据 | 每个状态一个子节点，见 [references\u002Fstate-machine.md](references\u002Fstate-machine.md) |\n| 状态对应动画，转移由动画条件驱动 | `AnimationTree` 的 `AnimationNodeStateMachine` |\n\n- 所有转移走一个入口函数，进出逻辑放在里面\n\n### 暂停\n\n`SceneTree.paused` 为 `true` 时，可暂停的节点停止 `_process`、`_physics_process` 和输入，物理模拟一并暂停。\n\n```gdscript\nextends Control\n\nfunc _ready() -> void:\n\tprocess_mode = Node.PROCESS_MODE_ALWAYS\n\thide()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tif event.is_action_pressed(\"pause\"):\n\t\tget_tree().paused = not get_tree().paused\n\t\tvisible = get_tree().paused\n\t\tget_viewport().set_input_as_handled()\n```\n\n| `process_mode` | 未暂停 | 暂停时 | 用于 |\n|---|---|---|---|\n| `PROCESS_MODE_INHERIT` 默认 | 同父级 | 同父级 | 普通节点，根节点按 PAUSABLE |\n| `PROCESS_MODE_PAUSABLE` | 运行 | 停止 | 游戏内容 |\n| `PROCESS_MODE_WHEN_PAUSED` | 停止 | 运行 | 暂停菜单内容 |\n| `PROCESS_MODE_ALWAYS` | 运行 | 运行 | 切换暂停的节点、背景音乐、转场 |\n| `PROCESS_MODE_DISABLED` | 停止 | 停止 | 关掉整棵子树 |\n\n- `create_timer` 的 `process_always` 默认 `true`，暂停时照常计时\n- `PROCESS_MODE_DISABLED` 不拦截已连接的信号，见 [references\u002Flifecycle.md](references\u002Flifecycle.md)\n- `Node.set_process(false)` 只停 `_process`，不停 `_physics_process` 和输入\n\n## 陷阱\n\n| 现象 | 做法 |\n|---|---|\n| 子节点 `_ready` 里父节点未就绪 | `_ready` 子先于父。依赖子节点的初始化放在父的 `_ready` |\n| `queue_free()` 后 `is_instance_valid` 仍为 `true` | 帧末才释放。判断销毁中用 `is_queued_for_deletion()` |\n| 物理回调里改碰撞体报 `Can't change this state while flushing queries` 或 `Function blocked during in\u002Fout signal` | `set_deferred` 或 `call_deferred`，见 [references\u002Flifecycle.md](references\u002Flifecycle.md) |\n| 手写 `.tscn` 的 `@export` 节点属性运行时为 `null` | 节点头写 `node_paths=PackedStringArray(...)`，见 [references\u002Flifecycle.md](references\u002Flifecycle.md) |\n| `%Name` 取不到 | 跨实例化子场景无效。代码 `add_child` 的节点要设 `owner` |\n| `await get_tree().process_frame` 报错 | 树外 `get_tree()` 为 `null`，先 `add_child` |\n| `change_scene_to_*` 后 `current_scene` 为 `null` | 帧末才切换，见 [references\u002Fscene-switching.md](references\u002Fscene-switching.md) |\n| 节点释放后 lambda 回调报错 | 用方法引用连接，对象释放时自动断开 |\n| 每帧 `get_node` `find_child` `get_nodes_in_group`，或 `..\u002FSibling` 路径 | `@onready` 缓存，或改 `@export` 和信号 |\n| 一个 `Level.gd` 管相机、HUD、生成、计时 | 按职责拆子场景，Level 只组装 |\n\n## 参考\n\n- [references\u002Fcsharp.md](references\u002Fcsharp.md)：C# 项目先读，本文各节示例的 C# 写法\n- [references\u002Flifecycle.md](references\u002Flifecycle.md)：回调顺序、构造期设值、`owner`、手写 `.tscn` 的 `node_paths`、`call_deferred`、释放与失效引用、禁用时的信号\n- [references\u002Fscene-switching.md](references\u002Fscene-switching.md)：`change_scene_to_*` 行为、自己做切换、加载界面\n- [references\u002Fenum-state.md](references\u002Fenum-state.md)：`enum` 加 `match` 完整示例\n- [references\u002Fstate-machine.md](references\u002Fstate-machine.md)：状态子节点模板、`AnimationTree` 状态机\n- https:\u002F\u002Fdocs.godotengine.org\u002Fen\u002Fstable\u002Ftutorials\u002Fbest_practices\u002Findex.html\n","# Godot 场景架构\n\n场景拆分、节点引用、节点通信、状态机、暂停与场景切换的约定。\n\n默认结构：一个概念一个 `.tscn`，脚本挂在场景根，对外只露 `@export` 属性、信号和少量方法。\n\n## 范围\n\n| 不含 | 去哪 |\n|---|---|\n| 内容摆进 `.tscn` 还是代码生成、脚本生成场景文件 | godot-scene-authoring |\n| 具体节点用法 | godot-2d godot-3d godot-ui godot-animation |\n| `Resource` 当数据、存档 | godot-resources-data |\n| `@tool` 与编辑器插件 | godot-editor-tooling |\n| C# 信号、导出、生命周期写法 | godot-csharp |\n| 失焦自动暂停、设置界面 | godot-ui |\n| 屏幕外停用、大量实体 | godot-performance |\n| 收尾音效、同时多声 | godot-audio |\n\n## 先查内置\n\n| 需求 | 用这个 | 别自己写 |\n|---|---|---|\n| 可复用对象 敌人 子弹 面板 | 独立 `.tscn` + `PackedScene.instantiate()` | 代码 `new` 整棵节点树 |\n| 同场景内的节点引用 | `%UniqueName` 或 `@onready` 缓存 | 长路径 `get_node(\"A\u002FB\u002FC\")`，每帧 `get_node` |\n| 场景外的目标引用 | `@export var target: Node2D` | 写死 `\u002Froot\u002FMain\u002FLevel\u002FPlayer` |\n| 一类对象批量通知 | `add_to_group` + `get_tree().call_group` | 手写注册表数组，全局事件总线 |\n| 子对象通知父对象 | 信号 | 子节点 `get_parent().foo()` |\n| 全局共享数据 | 自定义 `Resource`，或 autoload 只放全局状态 | Manager 套 Manager |\n| 状态切换 | `enum` + `match`、状态子节点、`AnimationTree` | 一串 `is_jumping` `is_attacking` bool |\n| 暂停菜单 | `SceneTree.paused` + `Node.process_mode` | 每个脚本判断 `is_paused` |\n| 多个场景共用逻辑 | `class_name` 组件节点 | 复制粘贴，深继承链 |\n| 场景切换 | `change_scene_to_file`、`change_scene_to_packed` | 手动 `free` 旧场景再 `add_child` |\n| 非节点的纯逻辑对象 | `RefCounted` 或 `Resource` | 继承 `Node` 只为存数据 |\n\n## 做法\n\n### 实例化\n\n```gdscript\nclass_name Bullet\nextends Area2D\n\nvar direction: Vector2 = Vector2.RIGHT\nvar speed: float = 400.0\n\nfunc _physics_process(delta: float) -> void:\n\tposition += direction * speed * delta\n```\n\n```gdscript\nclass_name Spawner\nextends Node2D\n\n@export var bullet_scene: PackedScene\n\nfunc fire(dir: Vector2) -> void:\n\tvar bullet := bullet_scene.instantiate() as Bullet\n\tbullet.direction = dir\n\tget_parent().add_child(bullet)\n\tbullet.global_position = global_position\n```\n\n- 初始参数在 `add_child` 前设，`_ready` 里可读\n- `global_position` 在 `add_child` 后设\n- `add_child` 前设 `global_position`：2D 按本地坐标算，3D 报错\n- 场景引用用 `@export var scene: PackedScene`，文件移动后引用不断\n- 同脚本内固定不变的小场景可用 `preload`\n- 代码生成节点并存进 `PackedScene` 时，每个节点设 `owner`，见 [references\u002Flifecycle.md](references\u002Flifecycle.md)\n\n### 节点引用\n\n```gdscript\nextends Node2D\n\n@export var target: Node2D\n@export_node_path(\"Marker2D\") var spawn_path: NodePath\n\n@onready var score: Label = %ScoreLabel\n@onready var sprite: Sprite2D = $Sprite2D\n@onready var spawn: Marker2D = get_node(spawn_path)\n\nfunc _process(_delta: float) -> void:\n\tif target != null:\n\t\tlook_at(target.global_position)\n```\n\n| 写法 | 用于 |\n|---|---|\n| `$Name` | 直接子节点 |\n| `%Name` | 同场景更深的节点，先在场景面板右键 `Access as Unique Name` |\n| `@export var x: Node2D` | 场景外的目标，Inspector 里连 |\n| `get_node_or_null` | 节点可能不存在 |\n\n- 引用用 `@onready` 缓存为带类型成员，不在 `_process` 里取\n- `@export` 节点引用在 `instantiate()` 返回时已解析\n- `@export` 节点引用在 `_enter_tree` 和 `_ready` 可用，`_init` 里是 `null`\n- 代码 `instantiate()` 的场景，场景外的引用由调用方赋值\n\n### 通信\n\n原则 call down, signal up。\n\n| 方向 | 做法 |\n|---|---|\n| 父到子 | 直接调方法或设属性 |\n| 子到父 | 子 `emit` 信号，父 `connect` |\n| 兄弟之间 | 经共同父节点转发，或各自 `@export` 对方 |\n| 子需要父提供的行为 | 父把方法赋给子的 `Callable` 属性 |\n\n```gdscript\nclass_name Health\nextends Node\n\nsignal changed(current: int, maximum: int)\nsignal died\n\n@export var maximum: int = 100\n\n@onready var current: int = maximum\n\nfunc damage(amount: int) -> void:\n\tcurrent = maxi(current - amount, 0)\n\tchanged.emit(current, maximum)\n\tif current == 0:\n\t\tdied.emit()\n```\n\n```gdscript\nextends CharacterBody2D\n\n@onready var health: Health = $Health\n\nfunc _ready() -> void:\n\thealth.died.connect(queue_free)\n```\n\n- 信号名用过去式：`died` `item_collected`\n- 信号只报告已发生的事，要对方做事就调方法\n- 成员初始化器读 `@export` 得到脚本默认值\n- 依赖 Inspector 所设值的初值用 `@onready`\n- 编辑器 Node 面板连的信号存在 `.tscn`，改方法名无提示。优先脚本里 `connect`\n\n### 分组\n\n```gdscript\nextends Node2D\n\nfunc raise_alarm() -> void:\n\tget_tree().call_group(\"guards\", \"alert\", global_position)\n```\n\n- 分组用作一类对象的广播通道，不当全局注册表\n- 加入分组：节点面板 Groups 页签，或 `add_to_group(\"guards\")`\n- `call_group_flags(SceneTree.GROUP_CALL_DEFERRED, ...)` 帧末执行，遍历中会增删节点时用\n- 场景唯一对象用 `get_first_node_in_group(\"player\")`，`_ready` 里取一次并缓存\n\n### Autoload\n\n用于跨场景存活的全局状态：存档槽、设置、场景切换器、跨关卡任务进度。`change_scene_to_*` 不释放 autoload。\n\n```ini\n[autoload]\n\nSettings=\"*res:\u002F\u002Fsrc\u002Fautoload\u002Fsettings.gd\"\n```\n\n- 能放进场景的就放进场景\n- 不做全局音效池，场景自带 `AudioStreamPlayer`\n- `*` 对应面板 Enable 列，开启后 GDScript 才有全局名\n- C# 不读 `*`，自己写静态 Instance 属性\n- autoload 的 `_ready` 早于主场景加载，取不到场景节点\n- 共享函数用 `class_name` + `static func`，不需要 autoload\n- 共享数据用自定义 `Resource`，不需要 autoload\n- 不建 GameManager、EventBus、UIManager\n- 不建信号总线，收发方无法追踪\n\n### 组合与继承\n\n```gdscript\nclass_name HurtBox\nextends Area2D\n\n@export var health: Health\n\nfunc _ready() -> void:\n\tarea_entered.connect(_on_area_entered)\n\nfunc _on_area_entered(area: Area2D) -> void:\n\tif area is HitBox:\n\t\thealth.damage(area.damage)\n```\n\n```gdscript\nclass_name HitBox\nextends Area2D\n\n@export var damage: int = 1\n```\n\n| 手段 | 用于 | 限制 |\n|---|---|---|\n| 组件子节点 | 多种对象共有的行为，如 `Health` `HurtBox`，不建 Damageable 基类 | 宿主用 `@export` 传入，不用 `get_parent()` |\n| 脚本继承 | 同类事物的细分 | 一层，要第三层先拆组件 |\n| 继承场景 | 同一模板的变体，如换贴图和数值的敌人 | 父场景改结构影响所有变体 |\n| `Editable Children` | 改子场景内部节点 | 改动存在宿主场景，父场景改结构后易失效 |\n\n### 状态机\n\n| 状态数与转移 | 用法 |\n|---|---|\n| 2 到 5 个，转移简单 | `enum State` + `match`，见 [references\u002Fenum-state.md](references\u002Fenum-state.md) |\n| 每个状态有进出逻辑和数据 | 每个状态一个子节点，见 [references\u002Fstate-machine.md](references\u002Fstate-machine.md) |\n| 状态对应动画，转移由动画条件驱动 | `AnimationTree` 的 `AnimationNodeStateMachine` |\n\n- 所有转移走一个入口函数，进出逻辑放在里面\n\n### 暂停\n\n`SceneTree.paused` 为 `true` 时，可暂停的节点停止 `_process`、`_physics_process` 和输入，物理模拟一并暂停。\n\n```gdscript\nextends Control\n\nfunc _ready() -> void:\n\tprocess_mode = Node.PROCESS_MODE_ALWAYS\n\thide()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tif event.is_action_pressed(\"pause\"):\n\t\tget_tree().paused = not get_tree().paused\n\t\tvisible = get_tree().paused\n\t\tget_viewport().set_input_as_handled()\n```\n\n| `process_mode` | 未暂停 | 暂停时 | 用于 |\n|---|---|---|---|\n| `PROCESS_MODE_INHERIT` 默认 | 同父级 | 同父级 | 普通节点，根节点按 PAUSABLE |\n| `PROCESS_MODE_PAUSABLE` | 运行 | 停止 | 游戏内容 |\n| `PROCESS_MODE_WHEN_PAUSED` | 停止 | 运行 | 暂停菜单内容 |\n| `PROCESS_MODE_ALWAYS` | 运行 | 运行 | 切换暂停的节点、背景音乐、转场 |\n| `PROCESS_MODE_DISABLED` | 停止 | 停止 | 关掉整棵子树 |\n\n- `create_timer` 的 `process_always` 默认 `true`，暂停时照常计时\n- `PROCESS_MODE_DISABLED` 不拦截已连接的信号，见 [references\u002Flifecycle.md](references\u002Flifecycle.md)\n- `Node.set_process(false)` 只停 `_process`，不停 `_physics_process` 和输入\n\n## 陷阱\n\n| 现象 | 做法 |\n|---|---|\n| 子节点 `_ready` 里父节点未就绪 | `_ready` 子先于父。依赖子节点的初始化放在父的 `_ready` |\n| `queue_free()` 后 `is_instance_valid` 仍为 `true` | 帧末才释放。判断销毁中用 `is_queued_for_deletion()` |\n| 物理回调里改碰撞体报 `Can't change this state while flushing queries` 或 `Function blocked during in\u002Fout signal` | `set_deferred` 或 `call_deferred`，见 [references\u002Flifecycle.md](references\u002Flifecycle.md) |\n| 手写 `.tscn` 的 `@export` 节点属性运行时为 `null` | 节点头写 `node_paths=PackedStringArray(...)`，见 [references\u002Flifecycle.md](references\u002Flifecycle.md) |\n| `%Name` 取不到 | 跨实例化子场景无效。代码 `add_child` 的节点要设 `owner` |\n| `await get_tree().process_frame` 报错 | 树外 `get_tree()` 为 `null`，先 `add_child` |\n| `change_scene_to_*` 后 `current_scene` 为 `null` | 帧末才切换，见 [references\u002Fscene-switching.md](references\u002Fscene-switching.md) |\n| 节点释放后 lambda 回调报错 | 用方法引用连接，对象释放时自动断开 |\n| 每帧 `get_node` `find_child` `get_nodes_in_group`，或 `..\u002FSibling` 路径 | `@onready` 缓存，或改 `@export` 和信号 |\n| 一个 `Level.gd` 管相机、HUD、生成、计时 | 按职责拆子场景，Level 只组装 |\n\n## 参考\n\n- [references\u002Fcsharp.md](references\u002Fcsharp.md)：C# 项目先读，本文各节示例的 C# 写法\n- [references\u002Flifecycle.md](references\u002Flifecycle.md)：回调顺序、构造期设值、`owner`、手写 `.tscn` 的 `node_paths`、`call_deferred`、释放与失效引用、禁用时的信号\n- [references\u002Fscene-switching.md](references\u002Fscene-switching.md)：`change_scene_to_*` 行为、自己做切换、加载界面\n- [references\u002Fenum-state.md](references\u002Fenum-state.md)：`enum` 加 `match` 完整示例\n- [references\u002Fstate-machine.md](references\u002Fstate-machine.md)：状态子节点模板、`AnimationTree` 状态机\n- https:\u002F\u002Fdocs.godotengine.org\u002Fen\u002Fstable\u002Ftutorials\u002Fbest_practices\u002Findex.html\n",{"name":5,"description":7},"master","d9cc24874d2a7b2d0f9fa2382a02c42969a1e092","skills\u002Fgodot-scene-architecture",0,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills","https:\u002F\u002Fgithub.com\u002FMindsMaster","Full-stack developer","2026-11-10 12:36:07",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add MindsMaster\u002Fgodot-claude-code-skills --skill godot-scene-architecture",{"tool":38,"command":39},"bunx","bunx skills add MindsMaster\u002Fgodot-claude-code-skills --skill godot-scene-architecture",{"tool":41,"command":42},"pnpm","pnpm dlx skills add MindsMaster\u002Fgodot-claude-code-skills --skill godot-scene-architecture","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-architecture\u002FSKILL.md",true,[46,52,56,60,64],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"references\u002Fcsharp.md","REFERENCE","参考文档",4584,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-architecture\u002Freferences\u002Fcsharp.md",{"path":53,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":54,"sourceHtmlUrl":55},"references\u002Fenum-state.md",2578,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-architecture\u002Freferences\u002Fenum-state.md",{"path":57,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":58,"sourceHtmlUrl":59},"references\u002Flifecycle.md",7896,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-architecture\u002Freferences\u002Flifecycle.md",{"path":61,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":62,"sourceHtmlUrl":63},"references\u002Fscene-switching.md",5672,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-architecture\u002Freferences\u002Fscene-switching.md",{"path":65,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":66,"sourceHtmlUrl":67},"references\u002Fstate-machine.md",5171,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-architecture\u002Freferences\u002Fstate-machine.md",[69,76,83,90,97,104],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7FBP7NJ4NTGA239X15MXQPK","godot-ui","写菜单 HUD 对话框 血条 设置界面 本地化 分辨率适配 UI 导航时用，做设置即时生效 窗口模式 全屏 窗口尺寸确认还原 失焦暂停时也用。Control 布局 Container anchors、项目级 Theme 统一字体、StyleBox、ProgressBar 血条、RichTextLabel、多分辨率 stretch aspect、tr() 本地化、手柄焦点导航、mouse_filter 吃点击、CanvasLayer HUD、弹窗 拖放。UI layout, theme, localization, settings menu, fullscreen, pause on focus loss.","https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7FBP23RTBQ2ZW9SKXE37SFS","godot-shaders-vfx","做受击闪白 受伤变白 命中闪烁 溶解 描边，或从 GDScript 与 C# 改 .gdshader 的 shader 参数 SetInstanceShaderParameter set_shader_parameter 时先用，多个敌人共用一份材质各自闪白也归这里。也管内置材质与 shader 的取舍、instance uniform、屏幕与深度纹理、GPUParticles 粒子、后处理顺序。shaders, hit flash, particles, post-processing.","https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-shaders-vfx\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7FBNVCNBKPFGQF5P5QJZMXK","godot-scene-authoring","在 Godot 4 里新做关卡、房间、HUD、菜单、NPC、道具、背景时用，决定内容摆进 .tscn 还是代码运行时搭。新建项目第一个场景，往已有项目加场景，打开场景一片空看不到东西，美术策划要在编辑器里直接看和调，自定义显示节点在编辑器里不显示，@tool 节点把材质 z_index 写进 tscn，确定性模拟 联机 服务器要读场景里摆的位置。先自查项目是摆在场景里还是运行时生成，再按结果新做或迁移。脚本生成 tscn、@tool 自绘节点、预制场景、_validate_property、internal 子节点、NOTIFICATION_EDITOR_PRE_SAVE、C# 重载。level authoring, WYSIWYG, prefab, data-driven, bake on save, empty scene, audit.","https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-authoring\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7FBNFF1K8A77X45BDBQCA6E","godot-resources-data","定义游戏数据表 配置 存档 资源加载时用。自定义 Resource class_name @export .tres 与 C# [GlobalClass]、JSON 与 Resource 怎么选、导入时把 JSON CSV 转成 Resource、资源共享与 duplicate local_to_scene、load preload 与线程加载进度条、user:\u002F\u002F 存档、导出后读不到 res:\u002F\u002F 目录。game data, custom resource, save game.","https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-resources-data\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M7FBNB7C2A6XE5E48XH5NC5D","godot-performance","排查卡顿 掉帧 帧率低 内存增长时用，也用于几百个怪物 子弹同屏、CharacterBody 拥挤变慢、每帧重建网格、线程池只用上两三个核、C# 跨界开销。先测再改 Profiler Monitors。不降画面与数量的内置解法 管理器统一驱动、MultiMesh、Server、对象池、空间哈希、WorkerThreadPool 分块、网格局部更新、物理插值、线程加载、着色器编译卡顿、每帧分配。Godot performance, stutter, many entities.","https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-performance\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":19},"01M7FBN56HHKYA7CVERRYTTAFK","godot-multiplayer","写联机 多人 主机权威 同步 后加入 断线重连时用。ENetMultiplayerPeer 建连、@rpc 与 multiplayer_authority、MultiplayerSpawner MultiplayerSynchronizer 与可见性、传输模式与通道、NAT 与端口转发、ENetConnection 自建传输、预测与校正、两进程无头验收。客户端看不到主机的效果、后加入缺状态、奖励只发给主机时也用。multiplayer rpc replication late join netcode client prediction.","https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-multiplayer\u002FSKILL.md",[],[]]