Example #1
0
        public void LoadOptions()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(SoundSettingsSave));

            using (FileStream stream = new FileStream(GetSavePath(fileName), FileMode.OpenOrCreate))
            {
                try
                {
                    Save = (SoundSettingsSave)serializer.Deserialize(stream);

                    // Sound
                    MasterSlider.value       = Save.SoundMaster;
                    MusicSlider.value        = Save.SoundMusic;
                    SoundEffectsSlider.value = Save.SoundSFX;
                    AnnouncerSlider.value    = Save.SoundAnnouncer;

                    Apply();
                }
                catch (Exception)
                {
                    stream.Close();
                    Apply();
                    SaveOptions();
                    Debug.Log("Could not open settings.");
                }
            }
        }
Example #2
0
        private void Start()
        {
            // Disable feedback text
            FeedbackText.SetText(string.Empty);
            FeedbackText.transform.parent.gameObject.SetActive(false);

            //Creates an empty settings file to load. This is because it will return null reference exceptions if it's not done first.
            DisplaySave = new DisplaySettingsSave();
            SoundSave   = new SoundSettingsSave();
            ControlSave = new ControlSettingsSave();
            InputSave   = new InputSettingsSave();

            // Setup buttons
            ButtonDisplay.interactable = false; // Set the display to be interactable by default

            ButtonDisplay.onClick.AddListener(delegate
            {
                PanelDisplay.SetActive(true);
                PanelSound.SetActive(false);
                PanelControls.SetActive(false);

                ButtonDisplay.interactable  = false;
                ButtonSound.interactable    = true;
                ButtonControls.interactable = true;
            });

            ButtonSound.onClick.AddListener(delegate
            {
                PanelDisplay.SetActive(false);
                PanelSound.SetActive(true);
                PanelControls.SetActive(false);

                ButtonDisplay.interactable  = true;
                ButtonSound.interactable    = false;
                ButtonControls.interactable = true;
            });

            ButtonControls.onClick.AddListener(delegate
            {
                PanelDisplay.SetActive(false);
                PanelSound.SetActive(false);
                PanelControls.SetActive(true);

                ButtonDisplay.interactable  = true;
                ButtonSound.interactable    = true;
                ButtonControls.interactable = false;
            });

            // Get components
            DisplaySettings = PanelDisplay.GetComponent <DisplaySettings>();
            SoundSettings   = PanelSound.GetComponent <SoundSettings>();
            ControlSettings = PanelControls.GetComponent <ControlSettings>();
            InputSettings   = PanelControls.GetComponent <InputSettings>();

            // Set the default screen
            PanelDisplay.SetActive(true);
            PanelSound.SetActive(false);
            PanelControls.SetActive(false);

            // Setup Options
            LoadSettings();
        }
Example #3
0
 public void Setup(SoundSettingsSave save)
 {
     Save = save;
 }