跳转到内容

Godot Quick Start

开始前请先完成 Godot 安装,确保 Core 插件已启用且 igp/general/app_id 已填写。

建议在游戏自己的启动节点中先订阅事件,再调用 IGP.initialize()。不要仅依赖 Autoload 已存在来判断 SDK 已就绪。

Godot 4.7.1 / 4.4.1:

extends Node
func _ready() -> void:
IGP.connection_changed.connect(_on_connection_changed)
IGP.authorization_changed.connect(_on_authorization_changed)
IGP.error_occurred.connect(_on_error_occurred)
var result: Dictionary = await IGP.initialize()
if not result.success:
push_error("%s: %s" % [result.code, result.message])
return
print("IGP ready: ", IGP.is_ready)

Godot 3.6.2:

extends Node
func _ready():
IGP.connect("connection_changed", self, "_on_connection_changed")
IGP.connect("authorization_changed", self, "_on_authorization_changed")
IGP.connect("error_occurred", self, "_on_error_occurred")
var pending = IGP.initialize()
var result = yield(pending, "completed") if pending is GDScriptFunctionState else pending
if not result.success:
push_error("%s: %s" % [result.code, result.message])
return
print("IGP ready: ", IGP.is_ready)

success 表示初始化请求完成;IGP.is_ready 还要求 Desktop Session 和正版校验均已就绪。不要用房间或 realtime 状态判断这些非联机能力是否可用。

  • IGP.is_attached:Desktop Session 已连接。
  • IGP.is_ready:Desktop Session 与正版校验已完成,可以进入受保护流程。
  • IGP.authorization.state:当前正版校验状态。
  • IGP.capabilities / IGP.supports_capability(...):当前桌面客户端实际提供的能力。

首次正版校验失败时,Core 默认提供带 QuitRetry 的原生窗口。可以在 igp/authorization_fallback/* 修改文案或关闭默认 UI;关闭 UI 不会改变授权状态。

调用可选功能前同时检查模块与 capability:

if IGP.compliance != null:
IGP.compliance.event_changed.connect(_on_compliance_event_changed)
if IGP.leaderboard != null and IGP.supports_capability(IGP.CAPABILITY_LEADERBOARD):
var result: Dictionary = await IGP.leaderboard.list()
print(result)

Compliance 的实名与防沉迷入口只存在于 IGP.compliance,不要从 Core 查找旧 alias。Compliance 默认窗口只阻断输入,暂停玩法系统和打开实名 WebView 仍由游戏负责。

  1. 启动 IGP 桌面客户端并登录测试账号。
  2. 使用正确 appId 运行项目;需要平台注入上下文时,从桌面客户端启动游戏。
  3. 确认初始化成功、Desktop Session attached、授权进入明确状态。
  4. 确认 capability 与安装的包和测试环境配置一致。
  5. 调用一项只读能力或测试成就,并检查返回的 successcodemessage

完整功能验证和现成交互界面见 Godot 测试工程