Skip to content

Mod Configuration

cheese3660 edited this page Feb 26, 2023 · 3 revisions

Creating a Configuration Class

using SpaceWarp.API.Configuration;
using Newtonsoft.Json;
namespace Namespace;
[JsonObject(MemberSerialization.OptOut)]
[ModConfig]
public class Config {
   ...
}

Configuration Fields

To create a new field do the following (this creates an input/toggle field in the config editor in Space Warp)

[ConfigField("name")]
[ConfigDefaultValue(3)] // Optional
public int name;

Configuration Sections

[ConfigSection("folder/in/menu")]
[ConfigField("name")]
...

Getting The Configuration From Your Mod

using SpaceWarp.API.Configuration;
.
.
.
ManagerLocator.TryGet(out ConfigurationManager configManager);
Config conf = null; //Config is the name of your configuration class
if (configManager.TryGet("mod_id",out var config)) conf = (Config)conf.configObject;