private CanvasGroupFader BuildModsPanel() { CanvasGroupFader modsPanel = Instantiate(credits, credits.transform.parent, false); modsPanel.name = "OverlayWindow_Mods"; // Set the title foreach (var text in modsPanel.GetComponentsInChildren <TextMeshProUGUI>()) { if (text.name == "TitleText") { // Disable the Babelfish localization text.GetComponent <Babelfish>().enabled = false; text.text = "Mods"; } } // Set the icon foreach (var image in modsPanel.GetComponentsInChildren <Image>()) { if (image.name == "TitleArtwork") { image.sprite = ResourcesManager.GetSpriteForAspect("knock"); } } // Clear the old content VerticalLayoutGroup content = modsPanel.GetComponentInChildren <VerticalLayoutGroup>(); foreach (Transform child in content.transform) { Destroy(child.gameObject); } // Get the font to use for the contents TMP_FontAsset font = LanguageManager.Instance.GetFont( LanguageManager.eFontStyle.BodyText, LanguageTable.targetCulture); // Add the intro text TextMeshProUGUI modText = new GameObject("ModsIntro").AddComponent <TextMeshProUGUI>(); modText.transform.SetParent(content.transform, false); modText.font = font; modText.fontSize = 24; modText.fontStyle = FontStyles.Bold; modText.alignment = TextAlignmentOptions.Center; modText.color = modText.faceColor = new Color32(193, 136, 232, 255); modText.margin = new Vector4(20, 20, 20, 10); modText.enableKerning = true; modText.text = "Currently active mods"; // Add entries for each mod foreach (var mod in _modManager.Mods.Values) { AddModEntry(mod.Id, $"{mod.Name} (v{mod.Version}), by {mod.Author}", font, content.transform); } return(modsPanel); }
private void BuildModsButton() { Button modsButton = Instantiate(purgeButton); modsButton.transform.SetParent(purgeButton.transform.parent); modsButton.transform.localScale = new Vector3(1, 1, 1); modsButton.transform.SetSiblingIndex(4); modsButton.GetComponentInChildren <TextMeshProUGUI>().text = "MODS"; foreach (var image in modsButton.GetComponentsInChildren <Image>()) { if (image.name == "TokenArt") { image.sprite = ResourcesManager.GetSpriteForAspect("knock"); } } modsButton.onClick = new Button.ButtonClickedEvent(); modsButton.onClick.AddListener(ShowModsPanel); modsButton.gameObject.SetActive(true); }