Typed game configuration
Files and project setup
- Install
GeWuYou.GFramework.GameandGeWuYou.GFramework.Game.SourceGenerators. - Put schemas under
schemas/. Put YAML files in the directory specified byx-gframework-config-path, with one record per file. - The NuGet generator includes
schemas/**/*.schema.jsonas compilation inputs. With project references, configureAdditionalFilesin the consuming project. - After building, use the generated tables and registration helpers in
GFramework.Game.Config.Generated.
Schema and data
The GodotIntegration example defines an integer ID and a speed range for each record:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"x-gframework-config-path": "config/gameplay",
"type": "object",
"additionalProperties": false,
"required": ["id", "speed"],
"properties": {
"id": { "type": "integer" },
"speed": { "type": "number", "minimum": 20, "maximum": 600 }
}
}# Copyright (c) 2025-2026 GeWuYou
# SPDX-License-Identifier: Apache-2.0
id: 1
speed: 220Set additionalProperties: false explicitly on objects. Declare one items schema for an array. Represent variations with explicit object fields and use supported object conditions for validation. See the configuration generator reference for keywords and diagnostics.
Load and read tables
using GFramework.Game.Config;
using GFramework.Game.Config.Generated;
var registry = new ConfigRegistry();
var loader = new YamlConfigLoader("config-root")
.RegisterAllGeneratedConfigTables();
await loader.LoadAsync(registry);Set config-root to the directory containing config/ and schemas/. After loading, resolve a generated table from the registry and look up records by ID. Provide the registry to consumers as an instance dependency. Use GameConfigBootstrap to manage loading and the reload handle together.
Godot exports and reloads
Use GodotYamlConfigLoader to read schema and YAML files from res://. Include these text files in the export preset. During development, enable hot reload for an accessible filesystem path. Log reload diagnostics and keep the previous table when a reload fails. Dispose the reload handle when the session ends.
To combine base and extension data, see content packs. To edit configuration, see the VS Code configuration tool.