Files
unity-application/Assets/Common/Scripts/SettingsScreen.cs
2023-05-14 20:18:29 +00:00

56 lines
1.4 KiB
C#

using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.UI;
/// <summary>
/// Manager for the settings screen
/// </summary>
public class SettingsScreen : MonoBehaviour
{
/// <summary>
/// Reference to the scene playable director
/// </summary>
public PlayableDirector directorEnterFromMainMenu;
/// <summary>
/// Reference to the 'hardware acceleration' toggle option
/// </summary>
public Toggle useGPUOption;
/// <summary>
/// Start is called before the first frame update
/// </summary>
void Start()
{
useGPUOption.onValueChanged.AddListener(ToggleGPU);
UpdateSettings();
directorEnterFromMainMenu.Play();
}
/// <summary>
/// Update the display of the user preferences
/// </summary>
private void UpdateSettings()
{
var pdc = PersistentDataController.GetInstance();
useGPUOption.isOn = pdc.IsUsingGPU();
}
/// <summary>
/// Toggle 'hardware acceleration' option
/// </summary>
private void ToggleGPU(bool state)
{
PersistentDataController.GetInstance().SetGPUUsage(state);
}
/// <summary>
/// Restore the user preferences to their default values
/// </summary>
public void RestoreSettings()
{
PersistentDataController.GetInstance().RestoreSettings();
UpdateSettings();
}
}