public void AddNewRuleset(List <RuleData> defaultRules = null) { //convert from json to object RulesetList rsets = JsonUtility.FromJson <RulesetList>( PlayerPrefs.GetString(c_RulesetsKey) ); //copy default rules if not null if (defaultRules != null) { rsets.list.Add(new RuleDataList(defaultRules, c_NewRulesetName)); } else { rsets.list.Add(new RuleDataList(c_NewRulesetName)); } //save PlayerPrefs.SetString(c_RulesetsKey, //convert from object to json JsonUtility.ToJson(rsets) ); PlayerPrefs.Save(); }
public void ChangeCurrentRulesetName(string str) {//convert from json to object RulesetList rsets = JsonUtility.FromJson <RulesetList>( PlayerPrefs.GetString(c_RulesetsKey) ); rsets.list[CurrentRulesetIndex].name = str; //save PlayerPrefs.SetString(c_RulesetsKey, //convert from object to json JsonUtility.ToJson(rsets) ); PlayerPrefs.Save(); }
public void SetMaxNeighbors(int ruleIndex, int newValue) { //convert from json to object RulesetList rsets = JsonUtility.FromJson <RulesetList>( PlayerPrefs.GetString(c_RulesetsKey) ); rsets.list[CurrentRulesetIndex].list[ruleIndex].m_MaxNumNeighbors = newValue; //save PlayerPrefs.SetString(c_RulesetsKey, //convert from object to json JsonUtility.ToJson(rsets) ); PlayerPrefs.Save(); }
internal void DeleteRule(int ruleIndex) { //convert from json to object RulesetList rsets = JsonUtility.FromJson <RulesetList>( PlayerPrefs.GetString(c_RulesetsKey) ); rsets.list[CurrentRulesetIndex].list.RemoveAt(ruleIndex); //save PlayerPrefs.SetString(c_RulesetsKey, //convert from object to json JsonUtility.ToJson(rsets) ); PlayerPrefs.Save(); }
public void AddNewRule(RuleData rd) { //convert from json to object RulesetList rsets = JsonUtility.FromJson <RulesetList>( PlayerPrefs.GetString(c_RulesetsKey) ); rsets.list[CurrentRulesetIndex].list.Add(rd); //save PlayerPrefs.SetString(c_RulesetsKey, //convert from object to json JsonUtility.ToJson(rsets) ); PlayerPrefs.Save(); }
private void DeleteRuleset(int index) { Debug.Assert(index > 0 && index < NumRulesets); //convert json to object RulesetList rsets = JsonUtility.FromJson <RulesetList>( PlayerPrefs.GetString(c_RulesetsKey) ); //delete ruleset rsets.list.RemoveAt(index); //save PlayerPrefs.SetString(c_RulesetsKey, //convert from object to json JsonUtility.ToJson(rsets) ); PlayerPrefs.Save(); }