internal static void OnMainMenuLoaded(MainMenuUI ui) { MainMenuUtils.AddMainMenuButton(ui, "Mods", () => { var g = MainMenuUtils.DisplayBlankPanel <BaseUI>(ui, "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"); FixStyles(h); h.GetComponent <Image>().color = Color.green; mainMenuUIPrefab = h; }
public static void CreateError(string error, bool doAbort = true) { SRCallbacks.OnMainMenuLoaded += ((u) => { var mainmen = MainMenuUtils.DisplayBlankPanel <BaseUI>(u, "SRML ERROR", () => Application.Quit()); var g = GameObject.Instantiate(mainmen.transform.GetChild(0).Find("Title").gameObject); 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(mainmen.transform.GetChild(0).Find("Title").gameObject); MonoBehaviour.Destroy(h.GetComponent <XlateText>()); h.GetComponent <TMP_Text>().enableWordWrapping = true; h.GetComponent <TMP_Text>().text = "Aborting mod loading..."; h.GetComponent <TMP_Text>().alignment = TextAlignmentOptions.Bottom; h.transform.SetParent(mainmen.transform.GetChild(0), 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(mainmen.transform.GetChild(0), 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); }); }