Documentation
Features
πŸŽ› Configs

πŸŽ› Configs

What are Configs

  • Configs are containers of serialized data, saved as ScriptableObjects.
  • If only a single piece of data exists, and does not have multiple entires, use Configs. If there will be multiple entries of a data asset, like enemies, cards or potions, use Libraries.
  • In essence, Configs are also Libraries, same as Resources, so it's a uniform tech stack.

Of course you can still use lists inside a Config, like the level order, which points to Guids of the LevelLibrary.

Advantages of Configs

  • A single place to access data
  • Easy to create new Configs or expand existing Configs
  • Change the behavior of the app by changing a few files
  • Use the full power of Odin Inspector to make it easy to read
  • Any discipline can change the values
  • Change at runtime to see the results instantly
  • AB Test anything by swapping out configs
  • Offload configs to a CDN, and update the game's parameters without an app store update
  • Remote Configs and AB Testing allows changing any Config variable

How to create Configs

Create a new config from the GameSuite preferences panel or create it yourself as just inheriting from ConfigAsset is all thats needed.

using GameSuite;
 
namespace Game
{
	public class GameConfig : ConfigAsset
	{
		// Add variables here.
	}
}

To create a list of levels which can be easily changed in the editor, just create a LevelConfig like in this example:

using GameSuite;
 
namespace Game
{
	public class LevelConfig : ConfigAsset
	{
		[Level]
		public List<Guid> Levels = new List<Guid>();
	}
}

How to access Configs

Use Configs.Get<T> and pass the type of the Config, which is a shortcut for Services.Get<ConfigService>().Get<T>.

GameConfig gameConfig = Configs.Get<GameConfig>();

No more hard coding

If you need a Guid of a specific Library Asset or Resource through code, do not be tempted to hard code the Guid.

Just create a Config (or add the value to an existing config) to get the Guid you need, like in this example:

namespace Game
{
    public class GameConfig : ConfigAsset
    {
		[Inventory]
		public Guid LevelCompletedCurrency;
    }
}

Then simply get the value through the config anywhere in the code base:

Guid currency = Configs.Get<GameConfig>().LevelCompletedCurrency;
 
// Get the currency amount from SaveData:
int currencyAmount = SaveData.Get<InventorySaveData>().GetAmount(currency);
 
// Get the library asset:
if (Libraries.Get<InventoryLibrary>().TryGet(currency, out InventoryAsset inventoryAsset))
{
	
}

Multiple config files

The ConfigAsset default inspector has the same Name and Enabled checkbox as any library, with the only difference being the added Primary checkbox.


Config inspector

This Primary checkbox indicates this config file is the one to use if there are multiple configs in use. When primary is disabled, GameSuite will use the first one thats available. AB Testing allows switching a config: disable the configs you do not want and enable the config you do want to use in that scenario.