⚙️
FPS Framework
Asset StoreFab
  • Get Started
    • Welcome!
    • Setup
  • Tutorials
    • Character
      • First-Person Controller
      • Inventory
      • Firearm
        • Basics
        • Advanced
        • Other
          • Spray pattern
          • Attachment System
          • Projectile System
      • Explosive
    • Systems
      • Audio System
      • Animation System
      • Interactions
        • Pickable
      • Save System
      • Settings System
    • Tools
      • Extension Methods
    • UI
      • FPS Counter
      • Get Name
      • Image Size Fitter
  • Other
    • Full Change Log
      • 2025 Change Log
      • 2024 Change Log
      • 2023 Change Log
      • 2022 Change Log
Powered by GitBook
On this page
  • Settings Preset Setup
  • Triggering Options
  • Scripting Settings Preset
  • Scripting
  • Writing Custom Functions
  • Saving & Loading

Was this helpful?

  1. Tutorials
  2. Systems

Settings System

An advanced settings system based on Reflection

PreviousSave SystemNextTools

Last updated 1 month ago

Was this helpful?

The Settings System in the FPS Framework is designed to provide everything you need to create and manage a settings menu using a single ScriptableObject. This system handles the organization and storage of settings, making it easy to integrate with your UI and game preferences.

However, if you prefer, you can create a simpler system on your own and still use the built-in to handle saving and loading settings. This gives you flexibility depending on how complex you want your settings management to be.

Settings Preset Setup

The Settings Preset is a ScriptableObject that can be created through the Create Asset menu. To create one:

  1. Right-click in the Project window.

  2. Navigate to Create > Akila > FPS Framework > Settings System.

  3. Choose any of the default preset options available.

This will generate a new Settings Preset asset that you can use to manage and configure game settings. These ScriptableObjects serve as examples, and while you can use them as they are, it's recommended to write your own custom ones or modify them to suit your specific needs, along with the default settings provided.

The message “There are no sections.” appears because the settings preset currently has no sections assigned.

But first—what is a section? A section is a logical grouping of related settings within the preset. For example, you might have sections like Graphics, Audio, Controls or Gameplay. Create/Remove one by clicking on + or - buttons.

Each section contains customizable Options. To modify them:

  • Click + button to add an option

  • Click - button to remove an option

These controls appear at the bottom of each section (as shown in the screenshot below the message "There are no options...").

Options let you fine-tune your gameplay experience for each category (Video, Audio, Input, etc.).

Each section is made up of 2 fields.

Name
Description

Name

The name identifies the option and is used to find or trigger it.

Function

The function called when the option is triggered.

The function called when the option is triggered. For testing, use the built-in print() function to understand how the system works.

Later, you can replace it with custom functions or other built-in functions as needed.

Triggering Options

Each option can be triggered using the Setting Applier component. The Setting Applier handles everything for you: it locates the appropriate UI elements, saves and loads data, applies the selected settings, and ensures they are preserved across sessions.

Make sure to attach the Setting Applier component only to UI elements such as Button, Slider, Dropdown, or similar components.

The warning in the Setting Applier component is happening because there is no Settings Manager component in the scene. It is recommended to add the Settings Manager to a dedicated GameObject in your scene or to your Game Manager.

The Settings Manager has two fields: AutoApply and Settings Presets List. The Settings Presets List holds all your settings presets. If AutoApply is enabled, any change in the UI will automatically trigger the Setting Applier to apply the updated settings.

Next, if you go back to your Setting Applier component, it should no longer display any errors.

If there's another warning, resolve it by assigning a settings preset to the Settings Preset field within the Settings Manager component.

If you click on the path to modify it, you will see the options and sections you defined, sorted in the format: PresetName/SectionName/OptionName. Select the option you want in the desired section, as this will be the option triggered when the Setting Applier component is activated from the UI element.

With this setup (When a UI element is attached to the Setting Applier or to one of its children or parents), whenever the UI element is interacted with, it will apply the option it refers to from the preset it's linked to.

If AutoApply is disabled, you can manually apply all settings by calling the function SettingApplier.ApplyAll().

Scripting Settings Preset

The Settings Preset was designed this way to allow for easy scripting. You have a lot of flexibility to code, as everything interacts indirectly using C# Reflection, which simplifies the coding process.

To code a custom settings preset, start by creating a new class, add the namespace Akila.FPSFramework, and change the inheritance to SettingsPreset.

Settings Preset Methods

print

Prints a message to the console.

Settings Preset Virtual Methods (Overridable)

Name
Description

OnAwake

Called from the settings manager before the first frame is drawn.

OnStart

Called from the settings manager after the first frame is drawn.

OnUpdate

Called from the settings manager each frame.

OnApplicationQuit

Called from the settings manager when quitting playmode or quiting the build.

Scripting

Start by adding the namespace Akila.FPSFramework in your custom class.

using Akila.FPSFramework;

Then change the class’s inheritance to SettingsPreset like this:

using Akila.FPSFramework;

public class MySettingsPreset : SettingsPreset
{

}

Remember, the SettingsPreset class inherits from ScriptableObject, so you need to add the attribute [CreateAssetMenu] before the start of your custom class. To use the class you've just written, go to the Project window in the Unity Editor and create a new asset file for the new settings preset you just created.

using Akila.FPSFramework;

[CreateAssetMenu]
public class MySettingsPreset : SettingsPreset
{

}

Writing Custom Functions

The system can only interact with functions that have either one parameter or no parameters at all. These parameters must be one of the following types: int, float, or bool.

Here’s a quick example use:

public void SetTextureQuality(int value)
{
     QualitySettings.masterTextureQuality = value;
}

By creating a new asset file for the class you wrote you can find your custom functions in any option’s Function field and if the option is triggered your custom function will be called.

The custom functions that are acceptable in the SettingsPreset can only have a single parameter.

Saving & Loading

The SettingApplier component will save and load the last saved options and apply them when the game starts automaticlly.

The Setting Applier component determines what to save and load based on the assigned Option Path, so make sure to avoid using duplicate paths in different Setting Applier components.

save system