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