Skip to content

LoL Engine Configuration System

A guide to using and customizing the configuration system in games built with LoL Engine.

Contents

  • Overview
  • Configuration Types
  • Setting Up Configuration
  • Accessing Configuration Values
  • Customizing Configuration
  • Available Configuration Options
  • Best Practices
  • Advanced Topics

Overview

The LoL Engine Configuration System provides a flexible way to define and access global settings across your game. It's built on Unity's ScriptableObject architecture integrated with ImprovedGameInitializer and ResourcePathConfig, allowing you to:

  • Define default values that work across all projects
  • Override specific values for each project
  • Organize settings into logical categories
  • Access configuration easily through centralized services
  • Extend with game-specific configuration

Configuration Types

The engine uses three primary configuration types:

  1. LoLEngineConfig: Core engine settings (logging, colors, save formats, etc.)
  2. LocalizationConfig: Language and localization settings
  3. SaveConfig: Data persistence and save system settings

Additional config types (Audio, Resource Management, etc.) are loaded via paths on ResourcePathConfig and assigned on ServiceConfiguration.

Setting Up Configuration

Method 1: Default Configuration (Automatic)

  1. Create the configuration assets:
  2. LoLEngineConfig: Create > LoLEngine > Config > LoLEngineConfig
  3. LocalizationConfig: Create > LoLEngine > Localization > Config
  4. SaveConfig: Create > LoLEngine > Data Persistence > Save Configuration
  5. ResourceManagementConfig: Create > LoLEngine > Config > Resource Management Config

  6. Name them appropriately (defaults):

  7. DefaultLoLEngineConfig.asset
  8. DefaultLocalizationConfig.asset
  9. DefaultSaveConfig.asset
  10. DefaultResourceManagementConfig.asset

  11. Place them under your ResourcePathConfig configs path (commonly Resources/Configs/)

  12. Add ImprovedGameInitializer to your first scene with ServiceConfiguration and ResourcePathConfig assigned.

ConfigurableServiceInitializer loads configs from the paths defined on ResourcePathConfig at runtime.

  1. Create configuration assets with project-specific names and values.

  2. Create and assign assets on ImprovedGameInitializer:

  3. ServiceConfiguration — which services are enabled + config asset references
  4. ResourcePathConfig — where configs live under Resources/

  5. Optionally subclass ImprovedGameInitializer for game-specific bootstrap:

using LoLEngine.Core.GameInitializer;
using LoLEngine.Core.ServiceManagement.Service;

public class MyGameInitializer : ImprovedGameInitializer
{
    [SerializeField] private MyGameConfig gameConfig;

    protected override void OnEngineInitialized()
    {
        base.OnEngineInitialized();

        if (gameConfig != null)
            ServiceLocator.Instance.Register(gameConfig);
    }
}

Accessing Configuration Values

Access configuration values through the LoLEngineConstants static class:

// Logging settings
Debug.Log($"Current log level: {LoLEngineConstants.Logging.DefaultLogLevel}");

// Game information
string gameName = LoLEngineConstants.Game.Name;
string gameVersion = LoLEngineConstants.Game.Version;

// Save settings
string saveExt = LoLEngineConstants.SaveLoad.SaveFileExtension;
bool compressSaves = LoLEngineConstants.SaveLoad.CompressSaveFiles;

// Color settings
string errorColor = LoLEngineConstants.Colors.DefaultLogErrorColor;

// Localization
SystemLanguage defaultLang = LoLEngineConstants.Localization.DefaultLanguage;

Services can access their specific configurations through dependency injection:

// Get localization config directly from service locator
var locConfig = ServiceLocator.Instance.Get<LocalizationConfig>();

// SaveSettings is NOT registered with the locator — it is produced from your
// SaveConfig asset via SaveConfig.ToRuntimeSettings(...). Resolve the save system:
var saveSystem = ServiceLocator.Instance.Get<ISaveSystem>();

// Get main engine config
var engineConfig = ServiceLocator.Instance.Get<LoLEngineConfig>();

Customizing Configuration

Per-Project Customization

For each project using LoL Engine:

  1. Create project-specific configurations for each needed type
  2. Assign ServiceConfiguration and config assets on ImprovedGameInitializer
  3. Set values specific to your project

Custom Game Initializer

Extend ImprovedGameInitializer for more customization:

using LoLEngine.Core.GameInitializer;
using LoLEngine.Core.ServiceManagement.Service;

public class MyGameInitializer : ImprovedGameInitializer
{
    [SerializeField] private MyGameConfig gameConfig;

    protected override void OnEngineInitialized()
    {
        base.OnEngineInitialized();

        if (gameConfig != null)
            ServiceLocator.Instance.Register(gameConfig);
    }
}

Runtime Modification

While most settings are read-only at runtime, you can create systems to modify and save user preferences:

// Example: Changing language at runtime
public void ChangeLanguage(SystemLanguage language)
{
    // Get localization service
    var localizationService = ServiceLocator.Instance.Get<ILocalizationService>();

    // Change language
    localizationService.SetLanguage(language);

    // Save the preference for next time
    PlayerPrefs.SetString("PreferredLanguage", language.ToString());
}

Available Configuration Options

LoLEngineConfig

Logging Options

  • engineLogLevel - Minimum log level for engine framework messages
  • gameLogLevel - Minimum log level for game-side GameLogger messages

Colors

  • defaultEngineMessageColor - Color for engine messages
  • defaultLogColor - Standard log color
  • defaultLogAlertColor - Warning log color
  • defaultLogErrorColor - Error log color

Game Information

  • Name - Game product name (from Unity settings)
  • Version - Game version (from Unity settings)

Save/Load System

File Extensions: - saveFileExtension - Extension for plain save files (default: ".sav") - obfuscatedSaveFileExtension - Extension for obfuscated saves (default: ".osav") - encryptedSaveFileExtension - Extension for encrypted saves (default: ".esave")

Protection Options (Priority: Obfuscation > Encryption > Plain): - obfuscateSaveFiles - Whether to obfuscate save files (default: true, recommended) - Use for normal game saves, settings, player progress - About 10x faster than encryption - Prevents casual save file editing - encryptSaveFiles - Whether to encrypt save files (default: false) - Use for sensitive data only (payment info, personal data) - Slower but stronger security - Overrides obfuscation if both are enabled - defaultEncryptionKey - Default key for save encryption (if encryptSaveFiles = true) - encryptionKeySeed - Custom seed for key generation

Compression: - compressSaveFiles - Whether to compress save files by default (recommended: true) - compressionLevelForSaveFiles - Level of compression to use (Fastest, Optimal, SmallestSize)

Versioning: - saveLoadVersion - Version string for save compatibility - saveVersion - Integer version for save compatibility

Storage: - saveDirectory - Directory where save files are stored (default: "Saves")

See Data Persistence — Save protection for detailed comparison of protection methods.

LocalizationConfig

  • defaultLanguage - Default language
  • supportedLanguages - List of supported languages
  • localizationTablesPath - Path to localization tables
  • useSystemLanguage - Whether to use system language if available

SaveConfig

  • defaultSaveSlot - Default save slot name
  • quickSaveSlot - Quick save slot name
  • autoSaveSlot - Auto-save slot name
  • maxSaveSlots - Maximum number of save slots (default: 10)
  • saveThumbnails - Whether to capture save thumbnails (default: true)
  • enableQuickSave - Enable the quick-save service (default: true)
  • enableAutoSave - Enable the auto-save service (default: true)
  • autoSaveInterval - Seconds between auto-saves (default: 300)
  • autoSaveOnSceneChange - Auto-save when the active scene changes (default: true)
  • restrictAutoSaveToGameplay - Only auto-save during gameplay scenes (default: true)
  • excludedSceneNames - Scenes where auto-save is suppressed (e.g. MainMenu, Boot, Loading)

Compression, encryption, save directory, and file extensions are configured on LoLEngineConfig, not SaveConfig.

Best Practices

Organization

  • Create a separate configuration per project
  • Keep default values reasonable for most uses
  • Document custom settings in your project's README

Performance

  • Access values only when needed
  • Cache values that are used frequently

Versioning

  • Create a new configuration when upgrading the engine
  • Maintain backward compatibility

Registration

  • Let ImprovedGameInitializer / ConfigurableServiceInitializer handle core configurations
  • Register custom configurations in custom initializers
  • Follow the same pattern for your own configs

Advanced Topics

Creating Game-Specific Settings

Extend the configuration system for your game:

  1. Create a subclass of ScriptableObject for your game config:
[CreateAssetMenu(fileName = "MyGameConfig", menuName = "MyGame/Config")]
public class MyGameConfig : ScriptableObject
{
    [Header("My Game Settings")]
    public float playerSpeed = 5f;
    public int maxHealth = 100;
    public Color playerColor = Color.blue;
}
  1. Register it in your custom ImprovedGameInitializer:
using LoLEngine.Core.GameInitializer;
using LoLEngine.Core.ServiceManagement.Service;

public class MyGameInitializer : ImprovedGameInitializer
{
    [SerializeField] private MyGameConfig gameConfig;

    protected override void OnEngineInitialized()
    {
        base.OnEngineInitialized();

        if (gameConfig != null)
            ServiceLocator.Instance.Register(gameConfig);
    }
}
  1. Access in your game code:
public class PlayerController : MonoBehaviour
{
    private MyGameConfig _gameConfig;

    private void Start()
    {
        _gameConfig = ServiceLocator.Instance.Get<MyGameConfig>();

        if (_gameConfig != null)
        {
            // Use config values
            GetComponent<Renderer>().material.color = _gameConfig.playerColor;
        }
    }
}

Configuration Inheritance

You can create layered configurations:

// Base game config
[CreateAssetMenu(fileName = "BaseGameConfig", menuName = "MyGame/BaseConfig")]
public class BaseGameConfig : ScriptableObject
{
    public float baseSpeed = 5f;
}

// Character-specific config that inherits base values
[CreateAssetMenu(fileName = "CharacterConfig", menuName = "MyGame/CharacterConfig")]
public class CharacterConfig : ScriptableObject
{
    [SerializeField] private BaseGameConfig baseConfig;

    // Override with character-specific value
    [SerializeField] private float characterSpeedMultiplier = 1.0f;

    // Computed property that uses base value
    public float ActualSpeed => baseConfig != null ?
        baseConfig.baseSpeed * characterSpeedMultiplier :
        5f * characterSpeedMultiplier;
}

Security Best Practices

  1. Don't Store Sensitive Data:
  2. Configuration assets are not encrypted and can be viewed in plain text
  3. Never store encryption keys, passwords, or API keys directly in configuration
  4. Use encryptionKeySeed instead of direct encryption keys

  5. Using Secure Key Generation:

  6. Instead of hardcoded encryption keys, use the encryptionKeySeed property
  7. The SecureKeyProvider will generate secure keys from this seed
  8. Leave encryptionKeySeed empty to use the internal secure mechanism

Example:

// Wired by ConfigurableServiceInitializer from LoLEngineConfig
string seed = engineConfig.encryptionKeySeed;
byte[] secureKey = SecureKeyProvider.GetEncryptionKey(seed);

// Create encryption service with secure key
var encryptionService = new AesEncryptionService(secureKey);