[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7FBP7NJ4NTGA239X15MXQPK":3,"skill-same:01M7FBP7NJ4NTGA239X15MXQPK":76},{"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},"01M7FBP7NJ4NTGA239X15MXQPK","godot-ui",null,"写菜单 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.","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-ui\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: godot-ui\ndescription: 写菜单 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.\n---\n\n# Godot UI\n\nControl 界面：场景里用 Container 和 anchors 搭，项目级 Theme 统一外观，用内置的 ProgressBar、RichTextLabel、翻译系统和焦点导航。\n\n## 范围\n\n| 不含 | 去哪 |\n|---|---|\n| 2D 世界里的节点摆放 | godot-2d |\n| 输入动作定义、改键 | godot-input |\n| 动画选型、数字滚动 | godot-animation |\n| 3D 场景里的 UI 面板 | godot-2d-in-3d |\n| `.tscn` 里导出节点引用的写法 | godot-scene-architecture |\n\n## 先查内置\n\n| 需求 | 用这个 | 别自己写 |\n|---|---|---|\n| 界面摆放 | 场景里的 Container 加 anchors preset | 代码里按 1920x1080 写死 `position` 和 `size` |\n| 边距 | MarginContainer | 手算偏移 |\n| 竖排 横排 网格 自动换行 | VBoxContainer HBoxContainer GridContainer 的 `columns` HFlowContainer VFlowContainer | 逐个设 `position`，双重循环算坐标，手写换行 |\n| 保持宽高比 | AspectRatioContainer | `_process` 里改 `size` |\n| 滚动列表 | ScrollContainer | 手写裁剪与拖动 |\n| 屏幕固定的 HUD | `CanvasLayer` 下放铺满的 Control | 世界场景里直接放 Control，随 Camera2D 滚走 |\n| 确认框 弹窗 | AcceptDialog ConfirmationDialog，`popup_centered()`，自带 `confirmed` `canceled` 信号与 Esc 关闭 | 手写居中 确定取消按钮与 Esc 处理 |\n| 拖放 悬浮提示 | `_get_drag_data` `_can_drop_data` `_drop_data`，`tooltip_text`，`_make_custom_tooltip` | `_gui_input` 里自己算拖拽与悬停计时 |\n| 折叠面板 | FoldableContainer 4.5+ | Button 加手动 `visible` |\n| 面板背景 | PanelContainer 或 Panel 加 StyleBoxFlat | ColorRect 叠 ColorRect |\n| 血条 经验条 | ProgressBar 或 TextureProgressBar | 改 ColorRect 的 `size.x` |\n| 全局字体颜色按钮样式 | 项目级 Theme | 到处 `add_theme_*_override` |\n| 同类控件多种样式 | theme type variation | 每个节点单独覆盖 |\n| 富文本 打字机效果 | RichTextLabel 的 BBCode 与 `visible_ratio` | 多个 Label 拼接 |\n| 玩家可见文本 | `tr()` 加翻译表 | 字符串硬编码 |\n| 按键提示 | `InputMap.action_get_events` | 写死 \"E\" |\n| 手柄菜单导航 | focus_neighbor 与 `grab_focus()` | 自己监听方向键切换高亮 |\n| 分辨率适配 | `display\u002Fwindow\u002Fstretch\u002Fmode` | 运行时按窗口大小手动缩放根节点 |\n\n## 做法\n\n### 布局\n\nHUD 与菜单在场景里搭：根 Control 用 `Full Rect` preset，其下嵌套 Container。\n\n```ini\n[node name=\"Hud\" type=\"Control\"]\nlayout_mode = 3\nanchors_preset = 15\nanchor_right = 1.0\nanchor_bottom = 1.0\nmouse_filter = 2\n\n[node name=\"Margin\" type=\"MarginContainer\" parent=\".\"]\nlayout_mode = 1\nanchors_preset = 15\nanchor_right = 1.0\nanchor_bottom = 1.0\ntheme_type_variation = &\"HudMargin\"\n\n[node name=\"Row\" type=\"HBoxContainer\" parent=\"Margin\"]\nlayout_mode = 2\n\n[node name=\"HealthBar\" type=\"ProgressBar\" parent=\"Margin\u002FRow\"]\ncustom_minimum_size = Vector2(240, 24)\nlayout_mode = 2\nshow_percentage = false\n```\n\n- 有 Camera2D 时 HUD 放 `CanvasLayer` 下，否则随相机移动\n- `CanvasLayer.layer` 默认 1，大的在上\n- 根 Control 设 `mouse_filter = 2` 即 IGNORE，否则吃掉所有点击\n- Container 决定子节点位置，子节点只表达尺寸需求\n\n| 子节点属性 | 作用 |\n|---|---|\n| `custom_minimum_size` | 尺寸下限 |\n| `size_flags_horizontal = 3` | 即 `Control.SIZE_EXPAND_FILL`，占满剩余空间 |\n| `size_flags_stretch_ratio` | 多个 EXPAND 子节点间按比例分配 |\n| 空 Control 加 EXPAND_FILL | 当弹簧，推开左右两组控件 |\n\n浮动控件，如跟随角色的血条、弹出提示，才用代码摆，仍用 preset：\n\n```gdscript\nextends Control\n\nfunc _ready() -> void:\n\tset_anchors_and_offsets_preset(Control.PRESET_CENTER_BOTTOM, Control.PRESET_MODE_MINSIZE, 32)\n```\n\n- `set_anchors_preset` 只改锚点，不改偏移\n- 一般用 `set_anchors_and_offsets_preset`\n- `PRESET_FULL_RECT` 铺满，`PRESET_TOP_WIDE` 贴顶拉宽\n\n### 容器限制\n\nContainer 在子节点变化和 `queue_sort()` 时重排，子节点的 `position` `size` 动画会被覆盖。\n\n- 动画改动 `scale` `modulate` `rotation`，或外包一层普通 Control\n- 按中心缩放、Label 换行、滚动区宽度见 [references\u002Flayout.md](references\u002Flayout.md)\n\n### Theme\n\n外观放一个 Theme 资源，项目设置里挂成全局默认：\n\n```ini\n[gui]\n\ntheme\u002Fcustom=\"res:\u002F\u002Fui\u002Ftheme\u002Fmain.tres\"\ntheme\u002Fcustom_font=\"res:\u002F\u002Fui\u002Ffonts\u002Fmain.ttf\"\n```\n\n- 对应 `gui\u002Ftheme\u002Fcustom` 与 `gui\u002Ftheme\u002Fcustom_font`\n- 任何 Control 不设 `theme` 也继承它，代码建的 UI 同样继承\n- 局部换主题：给 Control 设 `theme`，Control 与 Window 后代继承\n- 遇到其他类型的节点，继承断开\n- 颜色字号间距在 Theme 编辑器里改，脚本只读：`get_theme_color(&\"font_color\", &\"Label\")`\n- 同类控件多种样式用 theme type variation，单个 Label 用 `label_settings`\n- StyleBox 种类、变体、LabelSettings 见 [references\u002Ftheme.md](references\u002Ftheme.md)\n\n单个节点的一次性差异才用 override，如血条填充色随阵营变：\n\n```gdscript\nextends ProgressBar\n\nfunc set_team_color(color: Color) -> void:\n\tvar fill := get_theme_stylebox(&\"fill\").duplicate() as StyleBoxFlat\n\tfill.bg_color = color\n\tadd_theme_stylebox_override(&\"fill\", fill)\n```\n\n- `duplicate()` 必须有，否则改到 Theme 里共享的 StyleBox\n\n### 血条\n\nProgressBar 做纯色条，TextureProgressBar 做贴图条或环形条。样式在 Theme 里改 `fill` 与 `background`。\n\n| 属性 | 用法 |\n|---|---|\n| ProgressBar `show_percentage` | 默认 true，血条关掉 |\n| ProgressBar `step` | 默认 0.01 |\n| TextureProgressBar `step` | 默认 1.0，Tween 平滑时设 0.01 或更小，否则出阶梯 |\n| TextureProgressBar `fill_mode` | 径向值做冷却环、圆形血球，不用 shader |\n| TextureProgressBar `nine_patch_stretch` | 贴图拉伸，配 `stretch_margin_*` |\n\n缓动与受伤残影：\n\n```gdscript\nextends Control\n\n@onready var _front: ProgressBar = %Front\n@onready var _chip: ProgressBar = %Chip\n\nvar _tween: Tween\n\nfunc set_health(value: float) -> void:\n\t_front.value = value\n\tif _tween:\n\t\t_tween.kill()\n\t_tween = create_tween()\n\t_tween.tween_interval(0.4)\n\t_tween.tween_property(_chip, \"value\", value, 0.3).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)\n```\n\n- 前景条与残影条同位置叠放，残影条在下，填充用浅色\n- 前景条 `background` 设 StyleBoxEmpty，否则盖住残影条\n\n### RichTextLabel\n\n| 需求 | 用法 |\n|---|---|\n| BBCode | `bbcode_enabled = true`，写 `[b]` `[color=red]` `[url]` `[img]` |\n| 打字机 | Tween 驱动 `visible_ratio` 从 0 到 1，或改 `visible_characters` |\n| 高度随内容 | `fit_content = true`，放在 VBox 里常用 |\n| 链接点击 | 连 `meta_clicked`，`[url]` 默认点击无反应 |\n| 自定义效果 | 继承 RichTextEffect，`bbcode` 定标签名，`_process_custom_fx` 改 `CharFXTransform` |\n\n- 带自定义效果的 RichTextLabel 每帧处理，不用时隐藏\n- 标签清单与效果示例见 [references\u002Frichtext.md](references\u002Frichtext.md)\n\n### 多分辨率\n\n| 游戏 | `display\u002Fwindow\u002Fstretch\u002Fmode` | `display\u002Fwindow\u002Fstretch\u002Faspect` |\n|---|---|---|\n| 大多数游戏 | `canvas_items` | `expand` |\n| 像素风 | `viewport` | `keep` 或 `expand` |\n\n- 4.7 起新建项目默认 `canvas_items` 加 `expand`\n- 除 `keep` 外，HUD 靠 anchors 和 Container 贴边\n- 各取值、整数缩放、界面缩放、安全区见 [references\u002Flayout.md](references\u002Flayout.md)\n\n### 本地化\n\n玩家可见文本一律进翻译表，含按钮文字、提示、地点名。\n\n| 文本 | 写法 |\n|---|---|\n| 控件的 `text` | 填翻译键如 `MENU_START`，运行时自动翻译 |\n| 脚本拼接 | `tr(\"KEY\")` |\n| 带变量 | `tr(\"PICKED_UP\").format({item = name})`，占位符位置由译者调整 |\n| 复数 | `tr_n(\"%d item\", \"%d items\", count) % count` |\n| 同词不同义 | 第二个参数 context：`tr(\"Close\", \"Distance\")` |\n| 不翻译，如玩家名 | `auto_translate_mode` 设 `Node.AUTO_TRANSLATE_MODE_DISABLED` |\n| 切换语言 | `TranslationServer.set_locale(\"zh_CN\")`，存进设置，启动时恢复 |\n\n- 复数形式不止两种，不写 `if count == 1`\n- `tr_n` 前两个参数写带 `%d` 的英文原文，它是键也是回退文本\n- CSV 复数要 `?plural` 列 4.6+，4.5 及以前用 PO\n- `tr()` 的结果切换语言后不自动更新，在 `NOTIFICATION_TRANSLATION_CHANGED` 里重设：\n\n```gdscript\nextends Label\n\nvar _count: int = 0\n\nfunc _notification(what: int) -> void:\n\tif what == NOTIFICATION_TRANSLATION_CHANGED:\n\t\ttext = tr_n(\"%d item\", \"%d items\", _count) % _count\n```\n\n- 导入、注册、伪本地化、字体回退见 [references\u002Flocalization.md](references\u002Flocalization.md)\n\n### 焦点导航\n\n- 场景启动后须有控件拿焦点，否则方向键和手柄无反应\n- 写法：`$StartButton.grab_focus.call_deferred()`\n- 控件隐藏会丢焦点，面板重新显示要再抓\n- `focus_mode`、邻居、弹窗还焦点、无障碍名称见 [references\u002Ffocus-navigation.md](references\u002Ffocus-navigation.md)\n\n### 按键提示\n\n- 提示文本从 `InputMap.action_get_events` 取，改键后自动跟随\n- 绑定 `physical_keycode` 时用 `as_text_physical_keycode()`\n- 手柄按 `InputEventJoypadButton.button_index` 映射到自己的图标\n- 完整写法与键帽字母见 [references\u002Ffocus-navigation.md](references\u002Ffocus-navigation.md)\n\n### 输入顺序\n\n`_input`、`_gui_input`、`_shortcut_input`、`_unhandled_key_input`、`_unhandled_input`，依次传递。\n\n| 输入 | 放哪 |\n|---|---|\n| Control 内部拖动、自绘区域点击 | `_gui_input`，处理完 `accept_event()` |\n| 游戏世界的点击与按键 | `_unhandled_input`，UI 处理过的到不了 |\n| 暂停、截图等全局键 | `_unhandled_input` 或 `_shortcut_input` |\n| 按钮快捷键 | `BaseButton.shortcut` |\n\n- 不手写鼠标是否在 UI 上的判断\n\n### mouse_filter\n\n| 值 | 行为 | 默认值为它的控件 |\n|---|---|---|\n| `MOUSE_FILTER_STOP` | 吃掉事件，下层和 `_unhandled_input` 收不到 | Control Panel PanelContainer ColorRect Button ProgressBar RichTextLabel |\n| `MOUSE_FILTER_PASS` | 未 `accept_event()` 就冒泡给父 Control，到 STOP 为止 | 各 Container、TextureRect、TextureProgressBar |\n| `MOUSE_FILTER_IGNORE` | 不收事件，也不挡下层 | Label NinePatchRect |\n\n- 滚轮例外：`mouse_force_pass_scroll_events` 默认 true，STOP 也放行\n- HUD 根节点、装饰 ColorRect TextureRect Panel、按钮上的图标设 IGNORE\n- 子树关鼠标：`mouse_behavior_recursive = Control.MOUSE_BEHAVIOR_DISABLED` 4.5+\n\n## 陷阱\n\n| 现象 | 做法 |\n|---|---|\n| `custom_minimum_size` 设小了控件仍很大 | 它只是下限，文字内容也会撑大 |\n| 手写 `.tscn` 给导出的节点引用赋 NodePath，运行时为 null | 节点头补 `node_paths=PackedStringArray(\"player\")`，见 godot-scene-architecture |\n| 改 `get_theme_stylebox()` 的返回值，同类控件一起变 | 先 `duplicate()` |\n| 显示玩家名的 Label 被替换成译文 | 关 `auto_translate_mode`，名字与翻译键同名时会被翻译 |\n| 菜单打开时玩法重复触发 | 玩法不用 `ui_accept` 等内置动作 |\n\n## 参考\n\n- [references\u002Fcsharp.md](references\u002Fcsharp.md)：C# 项目先读，本文各节示例的 C# 写法\n- [references\u002Flocalization.md](references\u002Flocalization.md)：CSV 与 PO 导入、注册翻译、复数与上下文、TranslationServer、伪本地化、字体回退\n- [references\u002Ftheme.md](references\u002Ftheme.md)：StyleBox 种类与代码构造、theme type variation、LabelSettings\n- [references\u002Flayout.md](references\u002Flayout.md)：容器排版限制、stretch 各取值、整数缩放、界面缩放、安全区\n- [references\u002Ffocus-navigation.md](references\u002Ffocus-navigation.md)：手柄焦点导航、`focus_mode`、按键提示与键帽字母、设备切换、无障碍\n- [references\u002Frichtext.md](references\u002Frichtext.md)：BBCode 标签速查、自定义 RichTextEffect、打字机\n- [references\u002Fsettings-menu.md](references\u002Fsettings-menu.md)：设置即时生效、离开即保存与按应用保存、未保存状态显示、窗口模式与尺寸的确认倒计时和还原、全屏与窗口尺寸陷阱、启动参数恢复入口、失焦暂停\n- https:\u002F\u002Fdocs.godotengine.org\u002Fen\u002Fstable\u002Ftutorials\u002Fui\u002Findex.html\n- https:\u002F\u002Fdocs.godotengine.org\u002Fen\u002Fstable\u002Ftutorials\u002Fi18n\u002Findex.html\n- https:\u002F\u002Fdocs.godotengine.org\u002Fen\u002Fstable\u002Ftutorials\u002Fui\u002Fgui_navigation.html\n","# Godot UI\n\nControl 界面：场景里用 Container 和 anchors 搭，项目级 Theme 统一外观，用内置的 ProgressBar、RichTextLabel、翻译系统和焦点导航。\n\n## 范围\n\n| 不含 | 去哪 |\n|---|---|\n| 2D 世界里的节点摆放 | godot-2d |\n| 输入动作定义、改键 | godot-input |\n| 动画选型、数字滚动 | godot-animation |\n| 3D 场景里的 UI 面板 | godot-2d-in-3d |\n| `.tscn` 里导出节点引用的写法 | godot-scene-architecture |\n\n## 先查内置\n\n| 需求 | 用这个 | 别自己写 |\n|---|---|---|\n| 界面摆放 | 场景里的 Container 加 anchors preset | 代码里按 1920x1080 写死 `position` 和 `size` |\n| 边距 | MarginContainer | 手算偏移 |\n| 竖排 横排 网格 自动换行 | VBoxContainer HBoxContainer GridContainer 的 `columns` HFlowContainer VFlowContainer | 逐个设 `position`，双重循环算坐标，手写换行 |\n| 保持宽高比 | AspectRatioContainer | `_process` 里改 `size` |\n| 滚动列表 | ScrollContainer | 手写裁剪与拖动 |\n| 屏幕固定的 HUD | `CanvasLayer` 下放铺满的 Control | 世界场景里直接放 Control，随 Camera2D 滚走 |\n| 确认框 弹窗 | AcceptDialog ConfirmationDialog，`popup_centered()`，自带 `confirmed` `canceled` 信号与 Esc 关闭 | 手写居中 确定取消按钮与 Esc 处理 |\n| 拖放 悬浮提示 | `_get_drag_data` `_can_drop_data` `_drop_data`，`tooltip_text`，`_make_custom_tooltip` | `_gui_input` 里自己算拖拽与悬停计时 |\n| 折叠面板 | FoldableContainer 4.5+ | Button 加手动 `visible` |\n| 面板背景 | PanelContainer 或 Panel 加 StyleBoxFlat | ColorRect 叠 ColorRect |\n| 血条 经验条 | ProgressBar 或 TextureProgressBar | 改 ColorRect 的 `size.x` |\n| 全局字体颜色按钮样式 | 项目级 Theme | 到处 `add_theme_*_override` |\n| 同类控件多种样式 | theme type variation | 每个节点单独覆盖 |\n| 富文本 打字机效果 | RichTextLabel 的 BBCode 与 `visible_ratio` | 多个 Label 拼接 |\n| 玩家可见文本 | `tr()` 加翻译表 | 字符串硬编码 |\n| 按键提示 | `InputMap.action_get_events` | 写死 \"E\" |\n| 手柄菜单导航 | focus_neighbor 与 `grab_focus()` | 自己监听方向键切换高亮 |\n| 分辨率适配 | `display\u002Fwindow\u002Fstretch\u002Fmode` | 运行时按窗口大小手动缩放根节点 |\n\n## 做法\n\n### 布局\n\nHUD 与菜单在场景里搭：根 Control 用 `Full Rect` preset，其下嵌套 Container。\n\n```ini\n[node name=\"Hud\" type=\"Control\"]\nlayout_mode = 3\nanchors_preset = 15\nanchor_right = 1.0\nanchor_bottom = 1.0\nmouse_filter = 2\n\n[node name=\"Margin\" type=\"MarginContainer\" parent=\".\"]\nlayout_mode = 1\nanchors_preset = 15\nanchor_right = 1.0\nanchor_bottom = 1.0\ntheme_type_variation = &\"HudMargin\"\n\n[node name=\"Row\" type=\"HBoxContainer\" parent=\"Margin\"]\nlayout_mode = 2\n\n[node name=\"HealthBar\" type=\"ProgressBar\" parent=\"Margin\u002FRow\"]\ncustom_minimum_size = Vector2(240, 24)\nlayout_mode = 2\nshow_percentage = false\n```\n\n- 有 Camera2D 时 HUD 放 `CanvasLayer` 下，否则随相机移动\n- `CanvasLayer.layer` 默认 1，大的在上\n- 根 Control 设 `mouse_filter = 2` 即 IGNORE，否则吃掉所有点击\n- Container 决定子节点位置，子节点只表达尺寸需求\n\n| 子节点属性 | 作用 |\n|---|---|\n| `custom_minimum_size` | 尺寸下限 |\n| `size_flags_horizontal = 3` | 即 `Control.SIZE_EXPAND_FILL`，占满剩余空间 |\n| `size_flags_stretch_ratio` | 多个 EXPAND 子节点间按比例分配 |\n| 空 Control 加 EXPAND_FILL | 当弹簧，推开左右两组控件 |\n\n浮动控件，如跟随角色的血条、弹出提示，才用代码摆，仍用 preset：\n\n```gdscript\nextends Control\n\nfunc _ready() -> void:\n\tset_anchors_and_offsets_preset(Control.PRESET_CENTER_BOTTOM, Control.PRESET_MODE_MINSIZE, 32)\n```\n\n- `set_anchors_preset` 只改锚点，不改偏移\n- 一般用 `set_anchors_and_offsets_preset`\n- `PRESET_FULL_RECT` 铺满，`PRESET_TOP_WIDE` 贴顶拉宽\n\n### 容器限制\n\nContainer 在子节点变化和 `queue_sort()` 时重排，子节点的 `position` `size` 动画会被覆盖。\n\n- 动画改动 `scale` `modulate` `rotation`，或外包一层普通 Control\n- 按中心缩放、Label 换行、滚动区宽度见 [references\u002Flayout.md](references\u002Flayout.md)\n\n### Theme\n\n外观放一个 Theme 资源，项目设置里挂成全局默认：\n\n```ini\n[gui]\n\ntheme\u002Fcustom=\"res:\u002F\u002Fui\u002Ftheme\u002Fmain.tres\"\ntheme\u002Fcustom_font=\"res:\u002F\u002Fui\u002Ffonts\u002Fmain.ttf\"\n```\n\n- 对应 `gui\u002Ftheme\u002Fcustom` 与 `gui\u002Ftheme\u002Fcustom_font`\n- 任何 Control 不设 `theme` 也继承它，代码建的 UI 同样继承\n- 局部换主题：给 Control 设 `theme`，Control 与 Window 后代继承\n- 遇到其他类型的节点，继承断开\n- 颜色字号间距在 Theme 编辑器里改，脚本只读：`get_theme_color(&\"font_color\", &\"Label\")`\n- 同类控件多种样式用 theme type variation，单个 Label 用 `label_settings`\n- StyleBox 种类、变体、LabelSettings 见 [references\u002Ftheme.md](references\u002Ftheme.md)\n\n单个节点的一次性差异才用 override，如血条填充色随阵营变：\n\n```gdscript\nextends ProgressBar\n\nfunc set_team_color(color: Color) -> void:\n\tvar fill := get_theme_stylebox(&\"fill\").duplicate() as StyleBoxFlat\n\tfill.bg_color = color\n\tadd_theme_stylebox_override(&\"fill\", fill)\n```\n\n- `duplicate()` 必须有，否则改到 Theme 里共享的 StyleBox\n\n### 血条\n\nProgressBar 做纯色条，TextureProgressBar 做贴图条或环形条。样式在 Theme 里改 `fill` 与 `background`。\n\n| 属性 | 用法 |\n|---|---|\n| ProgressBar `show_percentage` | 默认 true，血条关掉 |\n| ProgressBar `step` | 默认 0.01 |\n| TextureProgressBar `step` | 默认 1.0，Tween 平滑时设 0.01 或更小，否则出阶梯 |\n| TextureProgressBar `fill_mode` | 径向值做冷却环、圆形血球，不用 shader |\n| TextureProgressBar `nine_patch_stretch` | 贴图拉伸，配 `stretch_margin_*` |\n\n缓动与受伤残影：\n\n```gdscript\nextends Control\n\n@onready var _front: ProgressBar = %Front\n@onready var _chip: ProgressBar = %Chip\n\nvar _tween: Tween\n\nfunc set_health(value: float) -> void:\n\t_front.value = value\n\tif _tween:\n\t\t_tween.kill()\n\t_tween = create_tween()\n\t_tween.tween_interval(0.4)\n\t_tween.tween_property(_chip, \"value\", value, 0.3).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)\n```\n\n- 前景条与残影条同位置叠放，残影条在下，填充用浅色\n- 前景条 `background` 设 StyleBoxEmpty，否则盖住残影条\n\n### RichTextLabel\n\n| 需求 | 用法 |\n|---|---|\n| BBCode | `bbcode_enabled = true`，写 `[b]` `[color=red]` `[url]` `[img]` |\n| 打字机 | Tween 驱动 `visible_ratio` 从 0 到 1，或改 `visible_characters` |\n| 高度随内容 | `fit_content = true`，放在 VBox 里常用 |\n| 链接点击 | 连 `meta_clicked`，`[url]` 默认点击无反应 |\n| 自定义效果 | 继承 RichTextEffect，`bbcode` 定标签名，`_process_custom_fx` 改 `CharFXTransform` |\n\n- 带自定义效果的 RichTextLabel 每帧处理，不用时隐藏\n- 标签清单与效果示例见 [references\u002Frichtext.md](references\u002Frichtext.md)\n\n### 多分辨率\n\n| 游戏 | `display\u002Fwindow\u002Fstretch\u002Fmode` | `display\u002Fwindow\u002Fstretch\u002Faspect` |\n|---|---|---|\n| 大多数游戏 | `canvas_items` | `expand` |\n| 像素风 | `viewport` | `keep` 或 `expand` |\n\n- 4.7 起新建项目默认 `canvas_items` 加 `expand`\n- 除 `keep` 外，HUD 靠 anchors 和 Container 贴边\n- 各取值、整数缩放、界面缩放、安全区见 [references\u002Flayout.md](references\u002Flayout.md)\n\n### 本地化\n\n玩家可见文本一律进翻译表，含按钮文字、提示、地点名。\n\n| 文本 | 写法 |\n|---|---|\n| 控件的 `text` | 填翻译键如 `MENU_START`，运行时自动翻译 |\n| 脚本拼接 | `tr(\"KEY\")` |\n| 带变量 | `tr(\"PICKED_UP\").format({item = name})`，占位符位置由译者调整 |\n| 复数 | `tr_n(\"%d item\", \"%d items\", count) % count` |\n| 同词不同义 | 第二个参数 context：`tr(\"Close\", \"Distance\")` |\n| 不翻译，如玩家名 | `auto_translate_mode` 设 `Node.AUTO_TRANSLATE_MODE_DISABLED` |\n| 切换语言 | `TranslationServer.set_locale(\"zh_CN\")`，存进设置，启动时恢复 |\n\n- 复数形式不止两种，不写 `if count == 1`\n- `tr_n` 前两个参数写带 `%d` 的英文原文，它是键也是回退文本\n- CSV 复数要 `?plural` 列 4.6+，4.5 及以前用 PO\n- `tr()` 的结果切换语言后不自动更新，在 `NOTIFICATION_TRANSLATION_CHANGED` 里重设：\n\n```gdscript\nextends Label\n\nvar _count: int = 0\n\nfunc _notification(what: int) -> void:\n\tif what == NOTIFICATION_TRANSLATION_CHANGED:\n\t\ttext = tr_n(\"%d item\", \"%d items\", _count) % _count\n```\n\n- 导入、注册、伪本地化、字体回退见 [references\u002Flocalization.md](references\u002Flocalization.md)\n\n### 焦点导航\n\n- 场景启动后须有控件拿焦点，否则方向键和手柄无反应\n- 写法：`$StartButton.grab_focus.call_deferred()`\n- 控件隐藏会丢焦点，面板重新显示要再抓\n- `focus_mode`、邻居、弹窗还焦点、无障碍名称见 [references\u002Ffocus-navigation.md](references\u002Ffocus-navigation.md)\n\n### 按键提示\n\n- 提示文本从 `InputMap.action_get_events` 取，改键后自动跟随\n- 绑定 `physical_keycode` 时用 `as_text_physical_keycode()`\n- 手柄按 `InputEventJoypadButton.button_index` 映射到自己的图标\n- 完整写法与键帽字母见 [references\u002Ffocus-navigation.md](references\u002Ffocus-navigation.md)\n\n### 输入顺序\n\n`_input`、`_gui_input`、`_shortcut_input`、`_unhandled_key_input`、`_unhandled_input`，依次传递。\n\n| 输入 | 放哪 |\n|---|---|\n| Control 内部拖动、自绘区域点击 | `_gui_input`，处理完 `accept_event()` |\n| 游戏世界的点击与按键 | `_unhandled_input`，UI 处理过的到不了 |\n| 暂停、截图等全局键 | `_unhandled_input` 或 `_shortcut_input` |\n| 按钮快捷键 | `BaseButton.shortcut` |\n\n- 不手写鼠标是否在 UI 上的判断\n\n### mouse_filter\n\n| 值 | 行为 | 默认值为它的控件 |\n|---|---|---|\n| `MOUSE_FILTER_STOP` | 吃掉事件，下层和 `_unhandled_input` 收不到 | Control Panel PanelContainer ColorRect Button ProgressBar RichTextLabel |\n| `MOUSE_FILTER_PASS` | 未 `accept_event()` 就冒泡给父 Control，到 STOP 为止 | 各 Container、TextureRect、TextureProgressBar |\n| `MOUSE_FILTER_IGNORE` | 不收事件，也不挡下层 | Label NinePatchRect |\n\n- 滚轮例外：`mouse_force_pass_scroll_events` 默认 true，STOP 也放行\n- HUD 根节点、装饰 ColorRect TextureRect Panel、按钮上的图标设 IGNORE\n- 子树关鼠标：`mouse_behavior_recursive = Control.MOUSE_BEHAVIOR_DISABLED` 4.5+\n\n## 陷阱\n\n| 现象 | 做法 |\n|---|---|\n| `custom_minimum_size` 设小了控件仍很大 | 它只是下限，文字内容也会撑大 |\n| 手写 `.tscn` 给导出的节点引用赋 NodePath，运行时为 null | 节点头补 `node_paths=PackedStringArray(\"player\")`，见 godot-scene-architecture |\n| 改 `get_theme_stylebox()` 的返回值，同类控件一起变 | 先 `duplicate()` |\n| 显示玩家名的 Label 被替换成译文 | 关 `auto_translate_mode`，名字与翻译键同名时会被翻译 |\n| 菜单打开时玩法重复触发 | 玩法不用 `ui_accept` 等内置动作 |\n\n## 参考\n\n- [references\u002Fcsharp.md](references\u002Fcsharp.md)：C# 项目先读，本文各节示例的 C# 写法\n- [references\u002Flocalization.md](references\u002Flocalization.md)：CSV 与 PO 导入、注册翻译、复数与上下文、TranslationServer、伪本地化、字体回退\n- [references\u002Ftheme.md](references\u002Ftheme.md)：StyleBox 种类与代码构造、theme type variation、LabelSettings\n- [references\u002Flayout.md](references\u002Flayout.md)：容器排版限制、stretch 各取值、整数缩放、界面缩放、安全区\n- [references\u002Ffocus-navigation.md](references\u002Ffocus-navigation.md)：手柄焦点导航、`focus_mode`、按键提示与键帽字母、设备切换、无障碍\n- [references\u002Frichtext.md](references\u002Frichtext.md)：BBCode 标签速查、自定义 RichTextEffect、打字机\n- [references\u002Fsettings-menu.md](references\u002Fsettings-menu.md)：设置即时生效、离开即保存与按应用保存、未保存状态显示、窗口模式与尺寸的确认倒计时和还原、全屏与窗口尺寸陷阱、启动参数恢复入口、失焦暂停\n- https:\u002F\u002Fdocs.godotengine.org\u002Fen\u002Fstable\u002Ftutorials\u002Fui\u002Findex.html\n- https:\u002F\u002Fdocs.godotengine.org\u002Fen\u002Fstable\u002Ftutorials\u002Fi18n\u002Findex.html\n- https:\u002F\u002Fdocs.godotengine.org\u002Fen\u002Fstable\u002Ftutorials\u002Fui\u002Fgui_navigation.html\n",{"name":5,"description":7},"master","d9cc24874d2a7b2d0f9fa2382a02c42969a1e092","skills\u002Fgodot-ui",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-ui",{"tool":38,"command":39},"bunx","bunx skills add MindsMaster\u002Fgodot-claude-code-skills --skill godot-ui",{"tool":41,"command":42},"pnpm","pnpm dlx skills add MindsMaster\u002Fgodot-claude-code-skills --skill godot-ui","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002FSKILL.md",true,[46,52,56,60,64,68,72],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"references\u002Fcsharp.md","REFERENCE","参考文档",1918,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002Freferences\u002Fcsharp.md",{"path":53,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":54,"sourceHtmlUrl":55},"references\u002Ffocus-navigation.md",3026,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002Freferences\u002Ffocus-navigation.md",{"path":57,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":58,"sourceHtmlUrl":59},"references\u002Flayout.md",2278,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002Freferences\u002Flayout.md",{"path":61,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":62,"sourceHtmlUrl":63},"references\u002Flocalization.md",8241,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002Freferences\u002Flocalization.md",{"path":65,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":66,"sourceHtmlUrl":67},"references\u002Frichtext.md",5937,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002Freferences\u002Frichtext.md",{"path":69,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Fsettings-menu.md",18866,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002Freferences\u002Fsettings-menu.md",{"path":73,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":74,"sourceHtmlUrl":75},"references\u002Ftheme.md",1409,"https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-ui\u002Freferences\u002Ftheme.md",[77,84,91,98,105,112],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"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":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"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":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7FBNN4WFN0PHM6P7SDH7V0J","godot-scene-architecture","拆分 Godot 4 场景与组织节点时用。PackedScene 组件复用、节点引用 @onready @export %UniqueName、信号与直接调用的选择、分组 call_group、Autoload 与普通节点、组合与继承、状态机、暂停 process_mode、queue_free 与 is_instance_valid、_ready 顺序、场景切换。scene tree architecture, signals, autoload.","https:\u002F\u002Fgithub.com\u002FMindsMaster\u002Fgodot-claude-code-skills\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-scene-architecture\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"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":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"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":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"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",[],[]]