Settings panel - decentraland/unity-explorer GitHub Wiki
Settings Panel Documentation
Overview (kindly provided by AI 😜)
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.
Architecture
The settings system follows the following structure:
Core Components
- 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
Module Types
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.
Settings Sections
The settings panel is organised into 4 main sections:
1. Graphics Section
- Visual quality settings
- Resolution and display options
- Performance graphics options
- V-Sync and frame rate controls
2. Sound Section
- Master volume control
- Individual volume sliders for:
- World sounds
- Music
- UI sounds
- Avatar sounds
- Voice chat
- Audio device selection
3. Controls Section
- Mouse sensitivity settings
- Camera controls
- Input device configuration
- Control scheme options
4. Chat Section
- Chat bubble visibility
- Chat privacy settings
- Audio modes for different chat types
- Blocked users management
Adding New Settings
Step 1: Create the Module View
Create a new view class inheriting from the appropriate base (slider in this example):
public class MyCustomSliderView : SettingsSliderModuleView
{
...
}
Step 2: Create the Controller
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();
}
}
Step 3: Add to Module Binding
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(),
};
Step 4: Configure in Settings Menu
- Open the
SettingsMenuConfiguration
asset in Unity - Navigate to the appropriate section (Graphics, Sound, Controls, or Chat)
- Add a new
SettingsGroup
or use an existing one - Add your module binding to the group's modules list
- Configure the module with appropriate title, description, and default values
Feature Flags
The settings system supports feature flag-based visibility to enable/disable entire sections or individual settings groups.
Using Feature Flags
- Define the Feature Flag: Add your feature flag to the
FeatureFlag
enum inFeatureFlagsStrings.cs
public enum FeatureFlag
{
// ... existing flags
MyNewFeature,
}
-
Apply to Settings Group: In the
SettingsMenuConfiguration
, set theFeatureFlagName
property on yourSettingsGroup
-
Runtime Behavior: The system automatically checks if the feature flag is enabled using:
FeatureFlagsConfiguration.Instance.IsEnabled(group.FeatureFlagName.GetStringValue())