English | Русский
Reach any ScriptableObject config by type.
Central, type-safe access to your ScriptableObject configs. Author configs as Config subclasses, gather them into a single ConfigCollection asset (auto-collected in the editor), place it in a Resources folder, call Initialize() once when you're ready, and ConfigProvider hands back any config via Get<T>().
Details
- .unitypackage — Releases
- UPM —
Window → Package Manager→+→Add package from git URL:https://github.com/SST-Systems/ConfigProvider.gitAppend#tagto pin a version. - Manual — clone or download, copy to
Assets/.
Unity 2021.3+
Standalone — no package dependencies beyond Unity.
| Type | Purpose |
|---|---|
Config |
Abstract ScriptableObject base for every config. |
ConfigCollection |
ScriptableObject holding the list of configs. In the editor it can auto-collect every Config asset (toggle + Find Force button). |
IConfigProvider |
void Initialize() + T Get<T>() where T : Config. |
ConfigProvider |
Loads the collection when you call Initialize(), then serves configs by type. |
// 1. Author configs
[CreateAssetMenu(menuName = "Config/PlayerConfig")]
public class PlayerConfig : Config
{
public int StartingHealth = 100;
}
// 2. Create a ConfigCollection asset:
// Create → Config → ConfigCollection, and put it in a Resources folder
// named "ConfigCollection". Enable "Auto Collect" (or press "Find Force")
// to gather every Config asset in the project.
// 3. Create the provider and initialize it yourself, whenever you're ready:
public class Game
{
private readonly IConfigProvider _configProvider = new ConfigProvider();
public void Boot()
{
_configProvider.Initialize(); // loads ConfigCollection from Resources
int hp = _configProvider.Get<PlayerConfig>().StartingHealth;
}
}- Call
Initialize()once before the firstGet<T>()— the provider is standalone, so you decide when to run it (a bootstrap step, a scene load, your own init pipeline, …). - The collection asset must be named
ConfigCollectionand live in aResourcesfolder — it is loaded viaResources.Load<ConfigCollection>("ConfigCollection"). - With Auto Collect on, an
AssetPostprocessorrefreshes the list whenever assets change; otherwise press Find Force in the inspector. Get<T>()logs an error and returnsnullif the requested config isn't in the collection.- Editor tooling (auto-collect,
Find Force) is guarded by#if UNITY_EDITORand stripped from builds.
Distributed under the MIT License. Free for personal and commercial use.
Author — Egor Shesterikov.
