Skip to content
André edited this page Mar 31, 2022 · 11 revisions

The MainUI class contains mainly all the functionality associated with the non-diegetic UI.

User Interface

You can see in the following diagram that the UI flow is simple to understand.

Functionality

MainUI.cs

Starting with the Main script, it ensures that all the preparations are set for the Main UI to work properly. It disables all the GameObjects that shouldn't be enabled when the game starts.

public partial class MainUI : MonoBehaviour
{
    [SerializeField] private GameObject optionsMenu;

    private void Awake()
    {
        optionsPanel.SetActive(false);
        audioPanel.SetActive(false);
        controlsPanel.SetActive(false);
        graphicsPanel.SetActive(false);
        
        optionsMenu.SetActive(false);
        
        LoadOptions();
    }
}

MainUI.MainMenu.cs / MainUI.OptionsMenu.cs / MainUI.Credits.cs

These scripts are responsible for the menu's functionality; They usually contain what most buttons do and a little bit of logic.

More specifically, the Options Menu contains extra functionality. It has multiple scripts for different Option groups (Audio | Controls | Graphics | Options).

Here's an example of one of those scripts:

MainUI.OptionsMenu.Options.cs

public partial class MainUI
{
    ...
    // Example of a Variable that is only going to be used in this script
    [SerializeField] private TextMeshProUGUI fieldOfViewLabel;
    ...
    // Example of a Method that is only going to be used in the Options panel
    public void FieldOfViewHandle(float newValue)
    {
        fieldOfViewLabel.text = newValue.ToString("F1").Replace(",", ".");
        gameOptions.fieldOfView = newValue;
        gameOptionsScriptableObject.fieldOfView = newValue;
        SaveOptions();
    }
    ...
}

MainUI.Save.cs

Additionally there's a script responsible for the saving system of the UI. It contains two methods responsible for the loading and saving of the data.

Clone this wiki locally