Web Analytics

godot-plugins-gtml

⭐ 54 stars Simplified Chinese by Niekvdm

GTML - Godot 标记语言

一个适用于 Godot 4.x 的插件,允许你使用 HTML 和 CSS 构建 UI。使用熟悉的网页技术创建游戏菜单、HUD 和面板。

功能

快速开始

1. 安装

addons/gtml/ 复制到你的项目中,并在 项目设置 → 插件 中启用。

2. 创建文件

menu.html:

menu.css:

.menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px;
    background-color: #1a1a2e;
}

h1 { font-size: 32px; color: #ffffff; }

button { padding: 12px 24px; background-color: #00d4ff; border-radius: 4px; color: #000000; transition: background-color 200ms ease; }

button:hover { background-color: #00a8cc; }

3. 添加 GmlView 节点

添加一个 GmlView 节点,并在检查器中设置 Html 路径Css 路径

4. 连接信号

func _ready():
    $GmlView.button_clicked.connect(_on_button_clicked)

func _on_button_clicked(method_name: String): match method_name: "on_play": get_tree().change_scene_to_file("res://game.tscn") "on_quit": get_tree().quit()

文档

示例

查看 addons/gtml/examples/ 获取可运行演示:

许可

MIT 许可协议

--- Tranlated By Open Ai Tx | Last indexed: 2025-12-23 ---