private INIFile INIGet(INIFilename ini) { if (_iniFileCreators[(int)ini] == null) { INIInit(ini); } GameObject iniFileCreator = _iniFileCreators[(int)ini]; return(iniFileCreator.GetComponent <INIFile>()); }
//INI //**Saves and loads string dictionaries** //**Uses Monobehavior in INIFile.cs, which requires it to be used as a component on a GO private void INIInit(INIFilename ini) { GameObject newGO = new GameObject(); newGO.transform.parent = GameObject.Find("Managers").transform; newGO.name = "Data_" + ini.ToString() + ".ini"; newGO.AddComponent <INIFile>(); newGO.GetComponent <INIFile>().Initialize(ini.ToString() + ".ini", false, false); _iniFileCreators[(int)ini] = newGO; }
public void INISave(Dictionary <string, string> data, INIFilename ini, string section) { INIFile iniFile = this.INIGet(ini); try{ foreach (string key in data.Keys) { iniFile.SetValue(section, key, data[key]); } } finally{ //commit the save iniFile.Flush(); } }
public void Startup() { State = ManagerState.Initializing; Debug.Log("Manager_Data initializing..."); //paths _dirDAT = Application.dataPath + "/Data/"; _dirJSON = Application.dataPath + "/Data/"; //initialize ini files foreach (INIFilename ini in INIFilename.GetValues(typeof(INIFilename))) { INIInit(ini); } //preferences.ini Dictionary <string, string> preferencesData = new Dictionary <string, string>(); preferencesData.Add("key", "value"); this.INISave(preferencesData, INIFilename.preferences, "section"); State = ManagerState.Started; Debug.Log("Manager_Data started..."); }
public Dictionary <string, string> INILoad(Dictionary <string, string> defaultData, INIFilename ini, string section) { INIFile iniFile = this.INIGet(ini); Dictionary <string, string> data = new Dictionary <string, string>(); foreach (string key in defaultData.Keys) { data[key] = iniFile.GetValue(section, key, defaultData[key]); } return(data); }