Godot:ConfigFile
INI스타일의 설정파일 제작 방법
Config File Sample
다음과 같은 ini파일 이다.
Save example
// Create new ConfigFile object.
var config = new ConfigFile();
// Store some values.
config.SetValue("Player1", "player_name", "Steve");
config.SetValue("Player1", "best_score", 10);
config.SetValue("Player2", "player_name", "V3geta");
config.SetValue("Player2", "best_score", 9001);
// Save it to a file (overwrite if already exists).
config.Save("user://scores.cfg");
Load example
var config = new ConfigFile();
// If the file didn't load, ignore it.
if (config.Load("user://scores.cfg") != Error.Ok) {
return;
}
// Iterate over all sections.
var data = new Dictionary<string, Variant>();
foreach (var section in config.GetSections()) {
data[section + ".player_name"] = config.GetValue(section, "player_name");
}
See also
- Godot
- Godot:SavingGames
- Godot:ConfigFile - 설정파일 저장시 사용.
- Godot:PacketPeer - 패킷 바이너리 직렬화
- Godot:ResourceSaver - 리소스(
.tres
) 파일 저장.