-
Notifications
You must be signed in to change notification settings - Fork 14
Settings panel
The Settings Panel in the Decentraland Unity Explorer is a modular, configurable system that allows users to adjust various aspects of their experience. The system is designed with flexibility in mind, supporting different types of controls and feature flag-based visibility.
The settings system follows the following structure:
- SettingsController: Main orchestrator that manages the settings panel lifecycle and navigation
- SettingsMenuConfiguration: ScriptableObject that defines the structure and content of the settings panel
- SettingsFeatureController: Base class for individual setting controllers that handle specific functionality
- SettingsModuleView: UI components that render the actual controls
The system supports three main types of controls:
-
Toggle Controls (
ToggleModuleBinding)- Simple on/off switches
- Examples: V-Sync, Chat Sounds, Hide Blocked Users
-
Slider Controls (
SliderModuleBinding)- Range-based controls with different display types
- Types: Numeric, Percentage, Time, Custom
- Examples: Volume controls, Sensitivity settings, Distance settings
-
Dropdown Controls (
DropdownModuleBinding)- Selection from predefined options
- Support for single and multi-select
- Examples: Graphics Quality, Resolution, Window Mode
Additional types of controls will need to be created by following the same structure of the existing ones.
The settings panel is organised into 4 main sections:
- Visual quality settings
- Resolution and display options
- Performance graphics options
- V-Sync and frame rate controls
- Master volume control
- Individual volume sliders for:
- World sounds
- Music
- UI sounds
- Avatar sounds
- Voice chat
- Audio device selection
- Mouse sensitivity settings
- Camera controls
- Input device configuration
- Control scheme options
- Chat bubble visibility
- Chat privacy settings
- Audio modes for different chat types
- Blocked users management
Create a new view class inheriting from the appropriate base (slider in this example):
public class MyCustomSliderView : SettingsSliderModuleView
{
...
}Create a controller that inherits from SettingsFeatureController:
public class MyCustomSettingController : SettingsFeatureController
{
private readonly MyCustomSliderView view;
public MyCustomSettingController(MyCustomSliderView view)
{
this.view = view;
view.SliderView.Slider.onValueChanged.AddListener(OnValueChanged);
}
private void OnValueChanged(float newValue)
{
}
public override void Dispose()
{
view.SliderView.Slider.onValueChanged.RemoveAllListeners();
}
}Add your new feature to the appropriate module binding enum and switch statement:
public enum SliderFeatures
{
// ... existing features
MY_CUSTOM_SLIDER_FEATURE,
}
SettingsFeatureController controller = Feature switch
{
// ... existing cases
SliderFeatures.MY_CUSTOM_SLIDER_FEATURE => new MyCustomSettingController(viewInstance, dataStore),
_ => throw new ArgumentOutOfRangeException(),
};- Open the
SettingsMenuConfigurationasset in Unity - Navigate to the appropriate section (Graphics, Sound, Controls, or Chat)
- Add a new
SettingsGroupor use an existing one - Add your module binding to the group's modules list
- Configure the module with appropriate title, description, and default values
The settings system supports feature flag-based visibility to enable/disable entire sections or individual settings groups.
-
Define the Feature Flag: Add your feature flag to the
FeatureFlagenum inFeatureFlagsStrings.cs
public enum FeatureFlag
{
// ... existing flags
MyNewFeature,
}-
Apply to Settings Group: In the
SettingsMenuConfiguration, set theFeatureFlagNameproperty on yourSettingsGroup -
Runtime Behavior: The system automatically checks if the feature flag is enabled using:
FeatureFlagsConfiguration.Instance.IsEnabled(group.FeatureFlagName.GetStringValue())