// Updates the characters and rule size based on the value you add. Adds random values as to not return an empty error. public void RuleSet(string newCharacters) { if (newCharacters != "" && !newCharacters.Contains(">")) { // if the user sets the character length to zero, to prevent bugs resets them both. if (int.Parse(newCharacters) <= 0) { newCharacters = 1.ToString(); Characters[0].transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "> X"; LSystemScript.characters[0] = characters[0]; Rules[0].transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "> F[+X]F[-X]+X"; LSystemScript.rules[0] = rules[0]; } else if (int.Parse(newCharacters) > 4) { newCharacters = 4.ToString(); } // Checks if the number is less than how many is active, if so deactivate them and remove them from the characters and rules. rulesetText.text = ""; int count = LSystemScript.characters.Count; for (int i = int.Parse(newCharacters); i < count; i++) { Characters[LSystemScript.characters.Count - 1].SetActive(false); Rules[LSystemScript.rules.Count - 1].SetActive(false); LSystemScript.characters.RemoveAt(LSystemScript.characters.Count - 1); LSystemScript.rules.RemoveAt(LSystemScript.rules.Count - 1); } // If the number is more than how many are active, then activate them and set them active. for (int i = 0; i < int.Parse(newCharacters); i++) { if (!Characters[i].activeSelf) { //Upon re-adding that character and rule, then reset it from the prefabs. switch (i) { case 1: Characters[i].SetActive(true); Characters[1].transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "> " + characters[1]; LSystemScript.characters.Add(characters[1]); Rules[1].transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "> FF"; LSystemScript.rules.Add(rules[1]); break; case 2: Characters[i].SetActive(true); Characters[2].transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "> " + characters[2]; LSystemScript.characters.Add(characters[2]); Rules[2].transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "> [+FX][FX][-FX]"; LSystemScript.rules.Add(rules[2]); break; case 3: Characters[i].SetActive(true); Characters[3].transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "> " + characters[3]; LSystemScript.characters.Add(characters[3]); Rules[3].transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "> XX"; LSystemScript.rules.Add(rules[3]); break; } } Characters[i].SetActive(true); Rules[i].SetActive(true); } } LSystemScript.CreateRules(); }