Home

Awesome

Config Assets

Simple & Lightweight solution for managing configuration assets in Unity projects

Install

  1. Install Editor Coroutines from Unity's package manager

    com.unity.editorcoroutines
    

    You can access the package manager by going to Window > Package Manager at the top bar in Unity

  2. Download & import the latest config-assets.unitypackage from here or the releases page.

Usage

First create a partial class and add the Config attribute to it

[Config]
public partial class MyConfig {
    // Your fields & attributes
}

Then add as many fields as you need, note that it must be Serializable by Unity for it to save. Anything that is valid for a ScriptableObject is valid here as well.

[Config]
public partial class MyConfig {
    [SerializeField] private string _myString;
    [SerializeField] private bool _myBool = true;

    //This also works
    public int myInt;
}

Your class is now accessible through a direct static access. <br>To use it just call YOUR_CLASS_NAME.YOUR_FIELD

int valueFromConfig = MyConfig.myInt;
<br>

Customization

The [Config] attribute has some properties to allow you to customize you configuration a bit:

AttributeDescriptionDefault
DisplayNameThe name used under Project Settingsnull (Will use the type name)
EnableProviderWhether or not to generate a SettingsProvidertrue
ScopeThe scope used by the SettingsProviderSettingsScope.Project
KeywordsThe keywords used by the SettingsProvidernone/empty
GenerateSingletonWhether or not to generate the .Instance propertytrue