godot-ui-theming by thedivergentai/gd-agentic-skills
npx skills add https://github.com/thedivergentai/gd-agentic-skills --skill godot-ui-theming主题资源、StyleBox 样式、字体管理和覆盖系统共同定义了一致的 UI 视觉标识。
具备动态切换、主题变体和回退处理功能的专家级主题管理器。
运行时主题切换以及 DPI/分辨率缩放管理。
使用级联主题根传播实现的动态深色/浅色模式。
专家级使用 theme_type_variation 进行语义化 UI 样式设计,无需复制场景。
安全的运行时 StyleBox 修改。演示了用于隔离覆盖的关键 duplicate() 模式。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
使用 NOTIFICATION_THEME_CHANGED 为生成的 UI 元素提供可靠的主题化。
在自定义 _draw() 逻辑中读取活动主题属性(颜色、字体)的模式。
通过将节点与父主题隔离并引用项目默认设置,确保 HUD 一致性。
通过 Tween 动画化 UI 样式。在复制后直接定位 StyleBox 属性。
使用 content_scale_factor 进行高质量、分辨率无关的缩放,以保持字体清晰度。
通过在类级别为 RenderingServer 缓存资源来修复“StyleBox 消失”的错误。
双向(RTL/LTR)UI 支持。根据布局方向动态切换主题变体。
_ready() 中创建 StyleBox — 实例化 StyleBoxFlat.new() 100 次会创建 100 个独立对象。应使用主题资源来实现共享继承。theme_type_variation 进行特定覆盖。theme.get_color() 来维护调色板的单一事实来源。add_theme_override 处理全局样式 — 这很脆弱。应在主题资源中定义样式,以便在整个项目中自动传播。_draw() 或 _process() 期间修改主题资源 — 频繁的布局重新计算将严重降低性能。StyleBoxEmpty 分配给焦点样式 — 这会无形中破坏控制器/键盘导航 [1]。务必提供可见的替代方案(例如,缩放变化)。set() 方法设置主题属性 — 调用 node.set("font_color", red) 会失败。必须使用专用的 add_theme_color_override() API [3]。expand_margin_* 来增加可点击区域 — 它只扩展视觉边界。应使用 StyleBox 上的 content_margin_* 或调整 Control 的大小以确保输入有效 [5]。_draw() 内部的局部变量 — 它们会在 RenderingServer 完成绘制之前被垃圾回收 [7]。应存储在类级别。theme_type_variation 在同一主题内创建轻量级的派生样式(例如 "DangerButton")[8]。corner_radius_all 快捷方式 — 这是在 StyleBoxFlat 中实现统一圆角的有用简写。# Create StyleBoxFlat for buttons
var style := StyleBoxFlat.new()
style.bg_color = Color.DARK_BLUE
style.corner_radius_top_left = 5
style.corner_radius_top_right = 5
style.corner_radius_bottom_left = 5
style.corner_radius_bottom_right = 5
# Apply to button
$Button.add_theme_stylebox_override("normal", style)
# Load custom font
var font := load("res://fonts/my_font.ttf")
$Label.add_theme_font_override("font", font)
$Label.add_theme_font_size_override("font_size", 24)
每周安装数
104
代码仓库
GitHub 星标数
59
首次出现
2026年2月10日
安全审计
安装于
gemini-cli100
codex100
opencode98
github-copilot95
kimi-cli94
amp94
Theme resources, StyleBox styling, font management, and override system define consistent UI visual identity.
Expert theme manager with dynamic switching, theme variants, and fallback handling.
Runtime theme switching and DPI/Resolution scale management.
Dynamic Dark/Light mode implementation using cascading theme root propagation.
Expert use of theme_type_variation for semantic UI styling without scene duplication.
Safe runtime StyleBox modification. Demonstrates the critical duplicate() pattern for isolated overrides.
Reliable theming for generated UI elements using NOTIFICATION_THEME_CHANGED.
Pattern for reading active Theme properties (colors, fonts) in custom _draw() logic.
Ensuring HUD consistency by isolating nodes from parent themes and referencing Project Defaults.
Animating UI styles via Tweens. Targets StyleBox properties directly after duplication.
High-quality resolution-independent scaling using content_scale_factor to maintain font crispness.
Fixing the "disappearing stylebox" bug by caching resources at the class level for the RenderingServer.
Bi-directional (RTL/LTR) UI support. Swaps theme variants dynamically based on layout direction.
_ready() for many nodes — Instantiating StyleBoxFlat.new() 100 times creates 100 unique objects. Use a Theme resource for shared heritage.theme_type_variation for specific overrides.theme.get_color() to maintain a single source of truth for your palette.add_theme_override for global styles — This is brittle. Define styles in a Theme resource for automatic propagation across the project._draw() OR _process() — Frequent layout recalculations will severely degrade performance.# Create StyleBoxFlat for buttons
var style := StyleBoxFlat.new()
style.bg_color = Color.DARK_BLUE
style.corner_radius_top_left = 5
style.corner_radius_top_right = 5
style.corner_radius_bottom_left = 5
style.corner_radius_bottom_right = 5
# Apply to button
$Button.add_theme_stylebox_override("normal", style)
# Load custom font
var font := load("res://fonts/my_font.ttf")
$Label.add_theme_font_override("font", font)
$Label.add_theme_font_size_override("font_size", 24)
Weekly Installs
104
Repository
GitHub Stars
59
First Seen
Feb 10, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykPass
Installed on
gemini-cli100
codex100
opencode98
github-copilot95
kimi-cli94
amp94
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
40,000 周安装
StyleBoxEmptyset() for theme properties — Calling node.set("font_color", red) fails. You MUST use the dedicated add_theme_color_override() API [3].expand_margin_* to increase clickable area — It only expands the VISUAL bounds. Use content_margin_* on the StyleBox or adjust the Control's size to ensure input works [5]._draw() — They will be garbage collected before the RenderingServer can finish drawing them [7]. Store at class level.theme_type_variation to create lightweight derived styles (e.g. "DangerButton") within the same Theme [8].corner_radius_all shortcut — It's a useful shorthand for uniform rounding in StyleBoxFlat.