static void Postfix( MainMenu __instance, ref GUIButtonMainmenu ____singleBtn, ref GUIButtonMainmenu ____headstartBtn, ref GUIButtonMainmenu ____levelsBtn, ref GUIButtonMainmenu ____multiBtn, ref GUIButtonMainmenu ____saveBtn, ref GUIButtonMainmenu ____saveAsBtn, ref GUIButtonMainmenu ____loadBtn, ref GUIButtonMainmenu ____joinBtn, ref GUIButtonMainmenu ____settingsBtn, ref GUIButtonMainmenu ____aboutBtn, ref GUIButtonMainmenu ____backToMapBtn, ref GUIButtonMainmenu ____quitSessionBtn, ref GUIButtonMainmenu ____quitGameBtn, ref GUIButtonMainmenu ____resumeBtn) { // ____singleBtn.gameObject.SetActive(true); ____headstartBtn.gameObject.SetActive(true); // ____levelsBtn.gameObject.SetActive(true); // ____multiBtn.gameObject.SetActive(true); // ____saveBtn.gameObject.SetActive(true); // ____saveAsBtn.gameObject.SetActive(true); // ____loadBtn.gameObject.SetActive(true); // ____joinBtn.gameObject.SetActive(true); // ____settingsBtn.gameObject.SetActive(true); // ____aboutBtn.gameObject.SetActive(true); // ____backToMapBtn.gameObject.SetActive(true); // ____quitSessionBtn.gameObject.SetActive(true); // ____quitGameBtn.gameObject.SetActive(true); // ____resumeBtn.gameObject.SetActive(true); }
static void Postfix(MainMenu __instance, GUIButtonMainmenu ____settingsBtn, ref TMP_Text ____version) { // ____version.color = Color.magenta; // ____version.margin = Vector4.one; // ____version.transform.position = new Vector3(-10, 5, 1); MonoBehaviour[] components = ____version.transform.gameObject.GetComponents <MonoBehaviour>(); foreach (var component in components) { Debug.Log($"Component: {component}"); } // TMPro.TextMeshProUGUI Debug.Log("CLONING VERSION TEXT"); _modLoaderText = UnityEngine.Object.Instantiate <GameObject>(____version.transform.gameObject, ____version.transform.parent); // _modLoaderText = UnityEngine.Object.Instantiate<GameObject>(new GameObject()); _modLoaderText.name = "ModLoader Text"; _modLoaderText.transform.position = new Vector3(10, 100, 1); RectTransform rect = _modLoaderText.GetComponent <RectTransform>(); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 200.0f); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 50.0f); TMP_Text text = _modLoaderText.GetComponent <TMP_Text>(); text.text = $"ModLoader v{ModLoader.ModLoaderVersion}\n{ModLoader.ModsLoaded} mods loaded"; text.color = Color.white; text.fontSize = 15; text.alignment = TextAlignmentOptions.Left; Debug.Log($"Cloned text: {text.text}"); Debug.Log($"Cloned text position: {_modLoaderText.transform.position}"); Debug.Log(_modLoaderText); GameObject modManager = Object.Instantiate(new GameObject()); modManager.name = "Persistent Mod Manager"; modManager.AddComponent <PersistentModManager>(); }
static void Postfix(MainMenu __instance, ref GUIButtonMainmenu ____quitGameBtn, GUIButtonMainmenu ____settingsBtn, Settings ____settings, MainMenu.IControl ____control, ref MainMenu.SessionType ____sessionType, ref TMP_Text ____version) { ____version.color = Color.magenta; ____version.margin = Vector4.one; ____version.transform.position = new Vector3(-10, 5, 1); // Don't show the disclaimer when going to the main menu // typeof(MainMenu).GetMethod("ShowDisclaimer", BindingFlags.NonPublic | BindingFlags.Instance) // .Invoke(__instance, new object[] { false }); // Removes the "are you sure you want to quit" warning // ____quitGameBtn.OnClick.RemoveAllListeners(); // ____quitGameBtn.OnClick.AddListener(new UnityAction(____control.QuitToDesktop)); // Instantiate the text // TMP_Text modInfoText = UnityEngine.Object.Instantiate<TMP_Text>(new TMP_Text(), new Vector3(500, 200, 0), Quaternion.identity); // // TMP_Text modInfoText = new TMP_Text(); // modInfoText.text = "Hello World"; // modInfoText.color = new Color(200, 200, 200); // GUIButtonSimple btn = new GUIButtonSimple(); GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(____settings.gameObject); UnityEngine.Object.Destroy((UnityEngine.Object)gameObject.GetComponent <ChooseSaveLoadFile>()); MainMenu_Initialize_Patch._modsPanel = gameObject.AddComponent <ModsPanel>(); MainMenu_Initialize_Patch._modsPanel.Initialize(); MainMenu_Initialize_Patch._modsButton = UnityEngine.Object.Instantiate <GUIButtonMainmenu>(____settingsBtn); MainMenu_Initialize_Patch._modsButton.name = "ModsBtn"; MainMenu_Initialize_Patch._modsButton.transform.SetParent(____settingsBtn.transform.parent); MainMenu_Initialize_Patch._modsButton.transform.position += Vector3.up * 50f; MainMenu_Initialize_Patch._modsButton.GetComponentInChildren <TextMeshProUGUI>(true).text = "Mods"; MainMenu_Initialize_Patch._modsButton.GetComponentInChildren <LocalizeThis>().enabled = false; MainMenu_Initialize_Patch._modsButton.transform.SetSiblingIndex(MainMenu_Initialize_Patch._modsButton.transform.GetSiblingIndex() - 1); MainMenu_Initialize_Patch._modsButton.OnClick.AddListener((UnityAction)(() => { // if (!MainMenu_Initialize_Patch._modsPanel.gameObject.activeSelf) // { // ModLogger.Log("{ModsPanel} Opening!"); // MainMenu_Initialize_Patch._modsPanel.Initialize(); // typeof(MainMenu).GetMethod("ShowContent", BindingFlags.Instance | BindingFlags.NonPublic).Invoke((object)__instance, new object[2] // { // (object) MainMenu_Initialize_Patch._modsPanel.gameObject, // (object) MainMenu_Initialize_Patch._modsButton // }); // } // else // { // ModLogger.Log("{ModsPanel} Closing!"); // typeof(MainMenu).GetMethod("HideCurrentContent", BindingFlags.Instance | BindingFlags.NonPublic).Invoke((object)__instance, (object[])null); // } ____control.StartHeadstartGame(); })); // Test player character in main menu. // CharacterLookManager. // Test spawn object. // _testObj = GameObject.CreatePrimitive(PrimitiveType.Cube); // _testObj.transform.Translate(0, 0, 0); // _testObj.transform.localScale = Vector3.one * 10.0f; // AssetBundle test // AssetBundle myAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.dataPath, "../CustomAssets/mytestbundle")); // var prefab = myAssetBundle.LoadAsset<GameObject>("test"); // _testObj = GameObject.Instantiate(prefab); // _testObj.transform.Translate(0, 0, 0); // _testObj.transform.localScale = Vector3.one * 5.0f; Transform startRoot = Camera.main.gameObject.transform.parent; FollowCamera followCam = GameObject.Instantiate(new FollowCamera()); followCam.transform.SetParent(startRoot); Camera.main.enabled = false; followCam.MainCamera.enabled = true; followCam.SetTargetObject(_testObj.transform); // Camera.main.GetComponent<FollowCamera>().SetTargetObject(_testObj.transform); // End Test player character in main menu ModLogger.Log("Main menu initialized! version text should be magenta now."); }