public static void CreateError(string error, bool doAbort = true) { SRCallbacks.OnMainMenuLoaded += ((u) => { var mainmen = MainMenuUtils.DisplayBlankPanelWithTranslation <BaseUI>(u, "ErrorUI", "t.srml_error", () => Application.Quit()); var panel = mainmen.transform.GetChild(0); var title = panel.Find("Title").gameObject; var g = GameObject.Instantiate(title); g.name = "ErrorText"; MonoBehaviour.Destroy(g.GetComponent <XlateText>()); g.GetComponent <TMP_Text>().text = error; g.GetComponent <TMP_Text>().alignment = TextAlignmentOptions.Top; g.GetComponent <TMP_Text>().fontSize *= .8f; g.GetComponent <TMP_Text>().enableWordWrapping = true; if (doAbort) { var h = GameObject.Instantiate(title); h.name = "AbortText"; h.GetComponent <TMP_Text>().enableWordWrapping = true; h.GetComponent <XlateText>().SetKey("t.srml_abort"); h.GetComponent <TMP_Text>().alignment = TextAlignmentOptions.Bottom; h.transform.SetParent(panel, false); var rect2 = h.GetComponent <RectTransform>(); rect2.anchorMin = new Vector2(0, 0); rect2.anchorMax = new Vector2(1, 1); rect2.offsetMax = new Vector2(-50, -100); rect2.offsetMin = new Vector2(50, 30); } g.transform.SetParent(panel, false); var rect = g.GetComponent <RectTransform>(); rect.anchorMin = new Vector2(0, 0); rect.anchorMax = new Vector2(1, 1); rect.offsetMax = new Vector2(-50, -100); rect.offsetMin = new Vector2(50, 30); }); }
internal static void OnMainMenuLoaded(MainMenuUI ui) { MainMenuUtils.AddMainMenuButtonWithTranslation(ui, "ModsButton", "b.mods", () => { var g = MainMenuUtils.DisplayBlankPanelWithTranslation <BaseUI>(ui, "ModsUI", "b.mods"); GameObject.Instantiate(mainMenuUIPrefab) .transform.SetParent(g.transform.GetChild(0), false); }).transform.SetSiblingIndex(5); if (mainMenuUIPrefab) { return; } var bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly() .GetManifestResourceStream(typeof(ModMenuUIHandler), "srml")); var h = bundle.LoadAsset <GameObject>("ModPanel"); h.AddComponent <ModMenuUI>().infoButtonPrefab = bundle.LoadAsset <GameObject>("ModInfoButton"); UIUtils.FixStyles(h); h.GetComponent <Image>().color = Color.green; mainMenuUIPrefab = h; }