public void update(SettingPairs settingPairs) { if (MENU != null) { this.settingPairs = settingPairs; Color gameMenuColor = default; if (gameMenuColorString != this.settingPairs.game_menu_color) { gameMenuColorString = this.settingPairs.game_menu_color; gameMenuColor = ImageTools.getColorFromString(gameMenuColorString); } MENU.SetActive(base.enabled); if (base.enabled) { MENU.transform.SetAsLastSibling(); for (int buttonIndex = 0; buttonIndex < NUMBER_OF_BUTTONS; ++buttonIndex) { BUTTON_STATES[buttonIndex] = MENU_BUTTONS[buttonIndex].GetComponent <ButtonListener>().isClicked(); if (gameMenuColor != default) { MENU_BUTTONS[buttonIndex].GetComponent <UnityEngine.UI.Image>().color = gameMenuColor; } } } } }
public GamePlayMenu(SettingPairs settingPairs) { this.settingPairs = settingPairs; gameMenuColorString = this.settingPairs.game_menu_color; CANVAS = GameObject.Find(DYNAMIC_CANVAS_NAME); MENU = GameObject.Instantiate(Resources.Load("Prefabs/Menu") as GameObject); MENU.transform.SetParent(CANVAS.transform); MENU.transform.localPosition = Vector3.zero; BUTTON_STATES = new bool[NUMBER_OF_BUTTONS]; MENU_BUTTONS = new GameObject[NUMBER_OF_BUTTONS]; MENU_BUTTON_LABELS = new GameObject[NUMBER_OF_BUTTONS]; for (int buttonIndex = 0; buttonIndex < NUMBER_OF_BUTTONS; ++buttonIndex) { GameObject button = GameObject.Instantiate(Resources.Load("Prefabs/MenuButton") as GameObject); GameObject buttonLabel = button.transform.Find(MENU_BUTTON_LABEL_NAME).gameObject; buttonLabel.GetComponent <TextMeshProUGUI>().text = processButtonLabel(buttonIndex); button.transform.SetParent(MENU.transform); button.transform.localScale = Vector3.one; MENU_BUTTONS[buttonIndex] = button; MENU_BUTTON_LABELS[buttonIndex] = buttonLabel; MENU_BUTTONS[buttonIndex].GetComponent <UnityEngine.UI.Image>().color = ImageTools.getColorFromString(gameMenuColorString); } MENU.SetActive(false); calculatePoints(); }