Esempio n. 1
0
    private void Load()
    {
        string filePath = System.IO.Path.Combine(Application.dataPath.Replace("/Assets", ""), fileName);

        if (File.Exists(filePath) == false)
        {
            return;
        }
        OptionSave save = JsonConvert.DeserializeObject <OptionSave>(File.ReadAllText(filePath));

        masterVolume.value = save.MasterVolume;
        MasterVolumeChange(save.MasterVolume);
        soundEffectVolume.value = save.SoundEffectVolume;
        SoundEffectVolumeChange(save.SoundEffectVolume);

        resolutionDropDown.value = resses.IndexOf(save.resolution.ToString());
        OnResolutionChange(resolutionDropDown.value);
        fullscreenDropDown.value = (int)save.resolution.fullScreenMode;
        SetFullscreen(fullscreenDropDown.value);
    }
Esempio n. 2
0
    private void Save()
    {
        string path = Application.dataPath.Replace("/Assets", "");

        if (Directory.Exists(path) == false)
        {
            // NOTE: This can throw an exception if we can't create the folder,
            // but why would this ever happen? We should, by definition, have the ability
            // to write to our persistent data folder unless something is REALLY broken
            // with the computer/device we're running on.
            Directory.CreateDirectory(path);
        }
        OptionSave save = new OptionSave {
            MasterVolume      = masterVolume.value,
            SoundEffectVolume = soundEffectVolume.value,
            resolution        = new CustomResolution(Screen.currentResolution)
        };
        string filePath = System.IO.Path.Combine(path, fileName);

        File.WriteAllText(filePath, JsonConvert.SerializeObject(save, new JsonSerializerSettings {
        }));
    }