private void initButton(int btnXLocation, int btnYLocation, String btnTextOn, System.Action btnActionOn, String btnTextOff, System.Action btnActionOff, String btnToolTip, Color?btnBackgroundColor = null, Color?btnTextColor = null, bool shouldSaveInConf = false, bool defaultPosition = false) { btnType = "ToggleButton"; button = UnityEngine.Object.Instantiate <GameObject>(QMStuff.ToggleButtonTemplate(), QMStuff.GetQuickMenuInstance().transform.Find(btnQMLoc), true); btnOn = button.transform.Find("Toggle_States_Visible/ON").gameObject; btnOff = button.transform.Find("Toggle_States_Visible/OFF").gameObject; initShift[0] = -4; initShift[1] = 0; setLocation(btnXLocation, btnYLocation); setOnText(btnTextOn); setOffText(btnTextOff); Text[] btnTextsOn = btnOn.GetComponentsInChildren <Text>(); btnTextsOn[0].name = "Text_ON"; btnTextsOn[0].resizeTextForBestFit = true; btnTextsOn[1].name = "Text_OFF"; btnTextsOn[1].resizeTextForBestFit = true; Text[] btnTextsOff = btnOff.GetComponentsInChildren <Text>(); btnTextsOff[0].name = "Text_ON"; btnTextsOff[0].resizeTextForBestFit = true; btnTextsOff[1].name = "Text_OFF"; btnTextsOff[1].resizeTextForBestFit = true; setToolTip(btnToolTip); //button.transform.GetComponentInChildren<UiTooltip>().SetToolTipBasedOnToggle(); setAction(btnActionOn, btnActionOff); btnOn.SetActive(false); btnOff.SetActive(true); if (btnBackgroundColor != null) { setBackgroundColor((Color)btnBackgroundColor); } else { OrigBackground = btnOn.GetComponentsInChildren <Text>().First().color; } if (btnTextColor != null) { setTextColor((Color)btnTextColor); } else { OrigText = btnOn.GetComponentsInChildren <UnityEngine.UI.Image>().First().color; } setActive(true); shouldSaveInConfig = shouldSaveInConf; if (defaultPosition == true)// && !ButtonSettings.Contains(this)) { setToggleState(true, false); } QMButtonAPI.allToggleButtons.Add(this); //ButtonSettings.InitToggle(this); }
public void initButtonX(int btnXLocation, int btnYLocation, String btnText, System.Action btnAction, String btnToolTip, Color?btnBackgroundColor = null, Color?btnTextColor = null, Color?backbtnBackgroundColor = null, Color?backbtnTextColor = null) { btnType = "NestedButton"; Transform menu = UnityEngine.Object.Instantiate <Transform>(QMStuff.NestedMenuTemplate(), QMStuff.GetQuickMenuInstance().transform); menuName = QMButtonAPI.identifier + btnQMLoc + "_" + btnXLocation + "_" + btnYLocation; menu.name = menuName; mainButton = new QMSingleButton(btnQMLoc, btnXLocation, btnYLocation, btnText, () => { QMStuff.ShowQuickmenuPage(menuName); } +btnAction, btnToolTip, btnBackgroundColor, btnTextColor); Il2CppSystem.Collections.IEnumerator enumerator = menu.transform.GetEnumerator(); while (enumerator.MoveNext()) { Il2CppSystem.Object obj = enumerator.Current; Transform btnEnum = obj.Cast <Transform>(); if (btnEnum != null) { UnityEngine.Object.Destroy(btnEnum.gameObject); } } if (backbtnTextColor == null) { backbtnTextColor = Color.white; } QMButtonAPI.allNestedButtons.Add(this); backButton = new QMSingleButton(this, 5, 2, "Back", () => { QMStuff.ShowQuickmenuPage(btnQMLoc); }, "Go Back", backbtnBackgroundColor, backbtnTextColor); }
private void initButton(float btnXLocation, float btnYLocation, String btnText, System.Action btnAction, String btnToolTip, Color?btnBackgroundColor = null, Color?btnTextColor = null) { btnType = "HalfButton"; button = UnityEngine.Object.Instantiate(QMStuff.SingleButtonTemplate(), QMStuff.GetQuickMenuInstance().transform.Find(btnQMLoc), true); initShift[0] = -1; initShift[1] = 0; setLocation(btnXLocation, btnYLocation); setButtonText(btnText); setToolTip(btnToolTip); setAction(btnAction); if (btnBackgroundColor != null) { setBackgroundColor((Color)btnBackgroundColor); } else { OrigBackground = button.GetComponentInChildren <UnityEngine.UI.Image>().color; } if (btnTextColor != null) { setTextColor((Color)btnTextColor); } else { OrigText = button.GetComponentInChildren <Text>().color; } setActive(true); QMButtonAPI.allHalfButtons.Add(this); }