Exemple #1
0
        public static void SaveSettings(SystemSettings systemSettings)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(SystemSettingsData));
            string        path       = Application.dataPath + "/SystemSettings.xml";
            FileStream    stream     = new FileStream(path, FileMode.Create);

            SystemSettingsData data = new SystemSettingsData();

            data.Fullscreen     = systemSettings.fullscreen;
            data.Resolution     = systemSettings.resolution;
            data.VsyncCount     = systemSettings.vsyncCount;
            data.GraphicsPreset = systemSettings.graphicsPreset;
            data.MasterVolume   = systemSettings.masterVolume;
            data.EffectsVolume  = systemSettings.effectsVolume;

            serializer.Serialize(stream, data);
            stream.Close();
        }
Exemple #2
0
        public static SystemSettingsData LoadSettings()
        {
            string path = Application.dataPath + "/SystemSettings.xml";

            if (File.Exists(path))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SystemSettingsData));
                FileStream    stream     = new FileStream(path, FileMode.Open);

                SystemSettingsData data = serializer.Deserialize(stream) as SystemSettingsData;
                stream.Close();

                return(data);
            }
            else
            {
                Debug.LogError("System Settings file not found");
                return(null);
            }
        }