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); }