Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/caneva20/ConfigAssets
Simple & Lightweight solution for managing configuration assets in Unity projects
https://github.com/caneva20/ConfigAssets
configs lightweight roslyn-generator scriptableobject source-generator unity unity3d
Last synced: 3 months ago
JSON representation
Simple & Lightweight solution for managing configuration assets in Unity projects
- Host: GitHub
- URL: https://github.com/caneva20/ConfigAssets
- Owner: caneva20
- License: mit
- Created: 2019-08-11T17:27:41.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-15T16:56:08.000Z (over 1 year ago)
- Last Synced: 2024-08-02T05:14:00.288Z (6 months ago)
- Topics: configs, lightweight, roslyn-generator, scriptableobject, source-generator, unity, unity3d
- Language: C#
- Homepage:
- Size: 308 KB
- Stars: 32
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Config Assets
Simple & Lightweight solution for managing configuration assets in Unity projects
## Install
1. Install `Editor Coroutines` from Unity's package manager
```shell
com.unity.editorcoroutines
```
> You can access the package manager by going to `Window > Package Manager` at the top bar in Unity2. Download & import the latest `config-assets.unitypackage` from [here](https://github.com/caneva20/ConfigAssets/releases/latest)
or the [releases](https://github.com/caneva20/ConfigAssets/releases) page.# Usage
First create a `partial class` and add the `Config` attribute to it
```C#
[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`](https://docs.unity3d.com/Manual/class-ScriptableObject.html) is valid here as well.```C#
[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.
To use it just call `YOUR_CLASS_NAME.YOUR_FIELD```` C#
int valueFromConfig = MyConfig.myInt;
```
* Whenever you get back to Unity, a new `.asset` file will be created for your configuration and it will be added
to `Preloaded assets` under the player settings.
* You can access your configuration through Unity's `Project Settings` under `Edit>Project Settings...` in the toolbar,
and then selecting the desired configuration under the `Config assets` section.# Customization
The `[Config]` attribute has some properties to allow you to customize you configuration a bit:
| Attribute | Description | Default |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
| `DisplayName` | The name used under `Project Settings` | `null` (Will use the type name) |
| `EnableProvider` | Whether or not to generate a [`SettingsProvider`](https://docs.unity3d.com/ScriptReference/SettingsProvider.html) | `true` |
| `Scope` | The [scope](https://docs.unity3d.com/ScriptReference/SettingsScope.html) used by the [`SettingsProvider`](https://docs.unity3d.com/ScriptReference/SettingsProvider.html) | `SettingsScope.Project` |
| `Keywords` | The keywords used by the [`SettingsProvider`](https://docs.unity3d.com/ScriptReference/SettingsProvider.html) | none/empty |
| `GenerateSingleton` | Whether or not to generate the `.Instance` property | `true` |