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:
- LoLEngineConfig: Core engine settings (logging, colors, save formats, etc.)
- LocalizationConfig: Language and localization settings
- 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)¶
- Create the configuration assets:
LoLEngineConfig: Create > LoLEngine > Config > LoLEngineConfigLocalizationConfig: Create > LoLEngine > Localization > ConfigSaveConfig: Create > LoLEngine > Data Persistence > Save Configuration-
ResourceManagementConfig: Create > LoLEngine > Config > Resource Management Config -
Name them appropriately (defaults):
DefaultLoLEngineConfig.assetDefaultLocalizationConfig.assetDefaultSaveConfig.asset-
DefaultResourceManagementConfig.asset -
Place them under your
ResourcePathConfigconfigs path (commonlyResources/Configs/) -
Add ImprovedGameInitializer to your first scene with ServiceConfiguration and ResourcePathConfig assigned.
ConfigurableServiceInitializer loads configs from the paths defined on ResourcePathConfig at runtime.
Method 2: Custom Configuration (Recommended)¶
-
Create configuration assets with project-specific names and values.
-
Create and assign assets on ImprovedGameInitializer:
ServiceConfiguration— which services are enabled + config asset references-
ResourcePathConfig— where configs live underResources/ -
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:
- Create project-specific configurations for each needed type
- Assign ServiceConfiguration and config assets on ImprovedGameInitializer
- 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 messagesgameLogLevel- Minimum log level for game-side GameLogger messages
Colors¶
defaultEngineMessageColor- Color for engine messagesdefaultLogColor- Standard log colordefaultLogAlertColor- Warning log colordefaultLogErrorColor- 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 languagesupportedLanguages- List of supported languageslocalizationTablesPath- Path to localization tablesuseSystemLanguage- Whether to use system language if available
SaveConfig¶
defaultSaveSlot- Default save slot namequickSaveSlot- Quick save slot nameautoSaveSlot- Auto-save slot namemaxSaveSlots- 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:
- 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;
}
- 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);
}
}
- 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¶
- Don't Store Sensitive Data:
- Configuration assets are not encrypted and can be viewed in plain text
- Never store encryption keys, passwords, or API keys directly in configuration
-
Use
encryptionKeySeedinstead of direct encryption keys -
Using Secure Key Generation:
- Instead of hardcoded encryption keys, use the
encryptionKeySeedproperty - The
SecureKeyProviderwill generate secure keys from this seed - Leave
encryptionKeySeedempty 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);