public void LoadSettings() { string path = Application.dataPath + "/" + filename; string jsonText = File.ReadAllText(path); data = JsonUtility.FromJson <SettingsJSON>(jsonText); }
public BlankSchool() { var lp = ReadConfFile("blank.config.json"); SettingsJSON config; if (lp != "") { config = JSON <SettingsJSON>(lp); } else { config = new SettingsJSON(); } DailyClassCount = config.DailyClassCount; FeedUrl = config.FeedUri; WeatherLocation = config.WeatherLocation; }
public BlankSchool() { var lp = Core.ReadConfig(config_file); SettingsJSON config; if (lp != "") { config = lp.ParseJSON <SettingsJSON>(); } else { config = new SettingsJSON(); } DailyClassCount = config.DailyClassCount; FeedUrl = config.FeedUri; WeatherLocation2 = config.WeatherLocation; }
// Load the settings from file public static void LoadSettings() { // If no settings file exists, create a blank one if (!File.Exists(settingsDir)) { File.WriteAllText(settingsDir, defaultSettingsJSON); } // Reset variables processControllers = null; // Read text from file string contents; using (StreamReader sr = new StreamReader(settingsDir, Encoding.UTF8)) { contents = sr.ReadToEnd(); } // Read data from JSON SettingsJSON jsonSettings = JsonConvert.DeserializeObject <SettingsJSON>(contents); if (!String.IsNullOrEmpty(jsonSettings.BoundIP)) { Server.boundIP = jsonSettings.BoundIP; } if (!String.IsNullOrEmpty(jsonSettings.Port)) { Server.port = jsonSettings.Port; } processControllers = new Dictionary <string, Profile>(); foreach (ProfileJSON profile in jsonSettings.Profiles) { processControllers[profile.Process] = profile.ToRegularProfile(); } }
/// <summary> /// Fetches settings dynamically on each time /// </summary> /// <returns></returns> IEnumerator FetchSettings() { WWW www = new WWW(serverAddress + "/settings"); yield return(www); if (!string.IsNullOrEmpty(www.error)) { print("Error fetching settings from " + www.url + " :: " + www.error + "."); yield break; } SettingsJSON settings = JsonUtility.FromJson <SettingsJSON>(www.text); DebugManager.Instance.PrintToRunningLog("Debug:" + settings.debugActive + " Period:" + settings.refreshPeriod + " Auto: " + settings.autoMode); debugCanvas.SetActive(settings.debugActive); scanPeriod = settings.refreshPeriod; autoMode = settings.autoMode; camResolution = settings.camResolution; }