Comment on page

Options Manager

The Options Manager component allows you to define options according to the project requirements. These can be settings related to graphics, sound, controls and other game elements. You can customize the different options according to what your game needs, creating a more customizable experience.

Adding new Options

  1. 1.
    First you will need to define how the option will look like in the user interface. You will be required to create the same setting for the Main Menu UI and the Game UI. To create a new option, locate the Options panel within the Pause Panels in the GAMEMANAGER object.
You will find the Tab_Buttons object, where the individual tab option buttons are located, and Tab_Panels, where the individual tab options are located.
To customize the displayed options, you can duplicate the current options and edit them accordingly, or create new options by dragging and dropping the option prefab to the parent group of options. The option prefabs can be found in the Prefabs/UI/Options folder.
You can choose between a slider option type, a radio option type, or an input option type.
  1. 2.
    After adding a new option to the UI, go to the Options Manager component and add the new option to the desired section by clicking the plus (+) button near the Options text.
  1. 3.
    Type a name for the option, which will later be used to reference the option in the option observer and which will be used to save the option state.
  2. 4.
    Assign the Option field with the newly added option that you defined in the UI.
  3. 5.
    If you have set the Option Type to Custom, you will need to select the Option Value that will be used to serialize and deserialize the option from the file. The Option Value will also be used within the Option Observer to manage the specified option type.
  1. 6.
    If you want to manage a custom option, you have three options:
    • You can observe the option value directly in your component using the ObserveOption() method.
    • You can use the CustomOptionObservers component where you can write a custom observer module.
    • Or you can use the OptionObserver component to call the specified reflected type. The reflected type must be the same type you defined in the Options Manager.

ObserveOption Method

Here is the code that observes the option directly (the value must be converted to the option type):
using UnityEngine;
namespace UHFPS.Runtime
public class TestObserver : MonoBehaviour
public bool BoolValue;
private void Start()
OptionsManager.ObserveOption("some_option", (value) => BoolValue = (bool)value);

CustomOptionObservers Method

In some circumstances, you will need to write a custom options observer that does not belong to any script, such as the Audio Listener class. In that case, you can write your own OptionObserverType.
using System;
using UnityEngine;
namespace UHFPS.Runtime
public class OptionListenerVolume : OptionObserverType
public override string Name => "Audio Listener Volume";
public override void OptionUpdate(object value)
if (value == null)
AudioListener.volume = (float)value;
After writing a custom OptionObserverType, you can add the CustomOptionObservers component to the desired location and add your newly created option to the list of option observers. The Observe Option Name must be the same as the option name in the Option Manager.

OptionObserver Method

In some cases, you just want to observe an option that reflects its value to an field, property, or method, in that case you can use the OptionObserver component. In my case, I only wanted to display the FPS Counter when the show_fps option is true, so I wrote a custom method that takes a bool parameter.