//Loads options and displays current option private void Start() { //Fixes position of scroll plane content rect optionListPlane.content.transform.position = optionListPos; colorListPlane.content.transform.position = colorListPos; //Makes sure the color picker is inactive ColorPickerBackground.SetActive(false); //Allows changing the states of cetain UI objects changableButtons = GameObject.FindGameObjectsWithTag("ChangableButton"); changableDropdowns = GameObject.FindGameObjectsWithTag("ChangableDropdown"); changableColors = GameObject.FindGameObjectsWithTag("ColorButton"); storedOptions = OptionStorage.GetSavedOptions(); optionButtons = new List <Button>(); DisplayOptionList(); colorButtons = new List <Button>(); localColors = OptionStorage.GetCurrent().GetColors(); DisplayColors(); EndEditing(); DisplayCurrentOptions(); }
//Edits the current options public void Edit() { //Disables the option buttons GameObject[] temp = GameObject.FindGameObjectsWithTag("OptionButton"); foreach (GameObject t in temp) { t.GetComponent <Button>().interactable = false; } //Enables all UI elements that change options changableColors = GameObject.FindGameObjectsWithTag("ColorButton"); changableButtons = GameObject.FindGameObjectsWithTag("ChangableButton"); nameInputField.interactable = true; nameInputField.text = OptionStorage.GetCurrent().GetName(); randomColorsToggle.interactable = true; for (int i = 0; i < changableColors.Length; i++) { changableColors[i].GetComponent <Button>().interactable = true; } for (int i = 0; i < changableButtons.Length; i++) { changableButtons[i].GetComponent <Button>().interactable = true; } for (int i = 0; i < changableDropdowns.Length; i++) { changableDropdowns[i].GetComponent <Dropdown>().interactable = true; } addOptionButton.interactable = false; }
//Displays the current option set's options on the various UI elements public void DisplayCurrentOptions() { for (short i = 0; i < 9; i++) { rulesDropdowns[i].value = OptionStorage.GetCurrent().GetRule(i); } edgeTypeDropdown.value = OptionStorage.GetCurrent().GetEdgeType(); nameInputField.text = OptionStorage.GetCurrent().GetName(); randomColorsToggle.isOn = OptionStorage.GetCurrent().ColorsAreRandom(); localColors = OptionStorage.GetCurrent().GetColors(); DisplayColors(); //Disallows editing of the Default options and the example options if (OptionStorage.GetCurrentOptionIndex() == 0 || OptionStorage.GetCurrentOptionIndex() == 1) { editButton.interactable = false; deleteButton.interactable = false; renameButton.interactable = false; } else { editButton.interactable = true; deleteButton.interactable = true; renameButton.interactable = true; } }
// Start is called before the first frame update void Start() { speed = 0.2f; //Gets access to current game options optionStorage = GameObject.FindObjectOfType <OptionStorage>(); currentOptions = OptionStorage.GetCurrent(); }
//Allows for renaming of the current option set public void Rename() { //Disables option buttons GameObject[] temp = GameObject.FindGameObjectsWithTag("OptionButton"); foreach (GameObject t in temp) { t.GetComponent <Button>().interactable = false; } addOptionButton.interactable = false; //Enables the name input field nameInputField.interactable = true; nameInputField.text = OptionStorage.GetCurrent().GetName(); }
//Saves current options public void AcceptChanges() { Options temp = OptionStorage.GetCurrent(); temp.SetName(nameInputField.text); temp.SetEdgeType((short)edgeTypeDropdown.value); temp.SetColorsAreRandom(randomColorsToggle.isOn); temp.SetColors(localColors); for (short i = 0; i < 9; i++) { temp.SetRule(i, (short)rulesDropdowns[i].value); } OptionStorage.SetCurrent(temp); optionButtons[OptionStorage.GetCurrentOptionIndex()].gameObject.GetComponentInChildren <Text>().text = temp.GetName(); EndEditing(); }
//Restores in game values to the values of the currently selected option set public void ResetOptions() { currentOptions = OptionStorage.GetCurrent(); DisplayOptions(); }