コード例 #1
0
 void Awake()
 {
     HoldGameControllerInEveryScene();
     settingsManager = new SettingsFileManager();
     GlobalSettings.SetGraphicsSettings();
     GlobalSettings.SetLanguage();
     GlobalSettings.HoldLanguageManager();
 }
コード例 #2
0
 void Awake()
 {
     HoldGameControllerInEveryScene();
     settingsManager = new SettingsFileManager();
     GlobalSettings.SetGraphicsSettings();
     GlobalSettings.SetLanguage();
     GlobalSettings.HoldLanguageManager();
 }
コード例 #3
0
        public void SaveLoad_PropertiesMatch()
        {
            FileInfo file = new FileInfo(Path.Combine(Path.GetTempPath(), $"{nameof(SettingsFileManagerTests)}.{nameof(this.SaveLoad_PropertiesMatch)}.xml"));

            try {
                SettingsFileManager <FakeSettings> settingsManager = new SettingsFileManager <FakeSettings>(file);
                settingsManager.Settings.NewProperty = "foo";
                settingsManager.Settings.IsAwesome   = true;
                settingsManager.Settings.Title       = "hello";
                FakeSettings savedSettings = settingsManager.Settings;
                settingsManager.Save();

                FakeSettings loadedSettings = new SettingsFileManager <FakeSettings>(file).Settings;

                Assert.AreEqual(savedSettings.NewProperty, loadedSettings.NewProperty);
                Assert.AreEqual(savedSettings.IsAwesome, loadedSettings.IsAwesome);
                Assert.AreEqual(savedSettings.Title, loadedSettings.Title);
            } finally {
                try { file.Delete(); } catch { }
            }
        }
コード例 #4
0
        public void LoadOldSettings_NewPropertyHasCorrectDefault()
        {
            FileInfo file = new FileInfo(Path.Combine(Path.GetTempPath(), $"{nameof(SettingsFileManagerTests)}.{nameof(this.LoadOldSettings_NewPropertyHasCorrectDefault)}.xml"));

            try {
                SettingsFileManager <OldFakeSettings> oldSettingsManager = new SettingsFileManager <OldFakeSettings>(file);
                oldSettingsManager.Settings.IsAwesome = true;
                oldSettingsManager.Save();
                string serialized;
                using (StreamReader reader = file.OpenText())
                    serialized = reader.ReadToEnd();
                using (StreamWriter writer = file.CreateText())
                    writer.Write(serialized.Replace(nameof(OldFakeSettings), nameof(FakeSettings)));

                FakeSettings settings = new SettingsFileManager <FakeSettings>(file).Settings;

                Assert.AreEqual(NEW_PROPERTY_DEFAULT, settings.NewProperty);
            } finally {
                try { file.Delete(); } catch { }
            }
        }