VixSettings Setup¶
Namespace: VixSettings
Basic Workflow¶
- Create setting assets from
Assets > Create > VixSettings > Setting. - Create a
SettingsRegistryfromAssets > Create > VixSettings > SettingsRegistry. - Add all setting assets to the registry.
- Create a storage asset, such as
JsonSettingStorage. - Add
SettingsManagerto a GameObject in the first loaded scene. - Assign the registry and storage assets to
SettingsManager.
SettingsManager is a singleton and uses DontDestroyOnLoad.
Creating Settings¶
Built-in setting asset types:
BoolSettingIntSettingFloatSettingStringSettingEnumSetting
Each setting has an ID. If the explicit ID field is empty, the asset name is used.
IDs must be unique within the SettingsRegistry.
Runtime Access¶
using VixSettings;
SettingsManager.Instance.SetValue("MasterVolume", 0.8f);
if (SettingsManager.Instance.TryGetSetting<float>("MasterVolume", out var volume))
{
float currentVolume = volume.Value;
}
Listening for Changes¶
using UnityEngine;
using VixSettings.Settings;
public class VolumeListener : MonoBehaviour
{
[SerializeField] private FloatSetting volume;
private void OnEnable()
{
volume.ValueChanged += OnVolumeChanged;
OnVolumeChanged(volume.Value);
}
private void OnDisable()
{
volume.ValueChanged -= OnVolumeChanged;
}
private void OnVolumeChanged(float value)
{
AudioListener.volume = value;
}
}
Storage¶
SettingsManager only saves overridden values.
Built-in storage options:
JsonSettingStorage: saves setting overrides to a JSON file. SupportspersistentDataPath, Documents, or a custom directory. Can pretty-print or compress data.PlayerPrefsSettingStorage: saves setting overrides to PlayerPrefs with a configurable key prefix.
Appliers¶
Setting appliers listen to a setting and apply the value when it changes.
Built-in appliers include:
FullscreenApplierMasterVolumeApplierQualityLevelApplier
Use appliers when the setting should immediately affect Unity or project state.
Samples¶
The package includes a Basic Settings Menu sample that can be imported from Unity Package Manager.