mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(UXAssist): reset cloned UI state
This commit is contained in:
1 parent
f611f2f9b3
commit
574919f1f0
21 files changed
+308
-58
No files matched your search
@@ -25,7 +25,10 @@ public static class LayoutHelper
|
||||
txt.color = new Color(1f, 1f, 1f, 0.4f);
|
||||
txt.alignment = TextAnchor.MiddleLeft;
|
||||
txt.fontSize = fontSize;
|
||||
txt.rectTransform.sizeDelta = new Vector2(txt.preferredWidth + 8f, txt.preferredHeight + 8f);
|
||||
txt.fontStyle = FontStyle.Normal;
|
||||
txt.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
txt.verticalOverflow = VerticalWrapMode.Overflow;
|
||||
txt.rectTransform.sizeDelta = new Vector2(Util.GetPreferredWidth(txt) + 8f, txt.preferredHeight + 8f);
|
||||
AddElement(x, y, txt.rectTransform, parent);
|
||||
return txt;
|
||||
}
|
||||
@@ -36,6 +39,7 @@ public static class LayoutHelper
|
||||
var dst = UnityEngine.Object.Instantiate(src);
|
||||
dst.gameObject.name = objName;
|
||||
var btn = dst.GetComponent<UIButton>();
|
||||
Util.ResetButton(btn);
|
||||
Util.NormalizeRectWithTopLeft(btn, x, y, parent);
|
||||
btn.tips.topLevel = true;
|
||||
btn.tips.tipTitle = label;
|
||||
@@ -54,6 +58,7 @@ public static class LayoutHelper
|
||||
var panel = UIRoot.instance.uiGame.statWindow.performancePanelUI;
|
||||
var btn = UnityEngine.Object.Instantiate(panel.cpuActiveButton);
|
||||
btn.gameObject.name = objName;
|
||||
Util.ResetButton(btn);
|
||||
var rect = Util.NormalizeRectWithTopLeft(btn, x, y, parent);
|
||||
rect.sizeDelta = new Vector2(width, rect.sizeDelta.y);
|
||||
var l = btn.gameObject.transform.Find("button-text").GetComponent<Localizer>();
|
||||
@@ -67,6 +72,10 @@ public static class LayoutHelper
|
||||
if (t != null)
|
||||
{
|
||||
t.text = text.Translate();
|
||||
t.color = Color.white;
|
||||
t.fontStyle = FontStyle.Normal;
|
||||
t.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
t.verticalOverflow = VerticalWrapMode.Overflow;
|
||||
}
|
||||
|
||||
t.fontSize = fontSize;
|
||||
|
||||
@@ -38,6 +38,7 @@ public class MyCheckButton : MonoBehaviour
|
||||
var go = Instantiate(UIRoot.instance.uiGame.beltWindow.reverseButton.gameObject);
|
||||
go.name = "my-checkbutton";
|
||||
go.SetActive(false);
|
||||
Util.ResetButton(go.GetComponent<UIButton>());
|
||||
var comp = go.transform.Find("text");
|
||||
if (comp)
|
||||
{
|
||||
@@ -46,6 +47,8 @@ public class MyCheckButton : MonoBehaviour
|
||||
{
|
||||
txt.text = "";
|
||||
txt.alignment = TextAnchor.MiddleCenter;
|
||||
txt.color = Color.white;
|
||||
txt.fontStyle = FontStyle.Normal;
|
||||
txt.rectTransform.anchorMax = new Vector2(0f, 1f);
|
||||
txt.rectTransform.anchorMin = new Vector2(0f, 1f);
|
||||
txt.rectTransform.pivot = new Vector2(0f, 1f);
|
||||
@@ -82,6 +85,7 @@ public class MyCheckButton : MonoBehaviour
|
||||
|
||||
cb.rectTrans = rect;
|
||||
cb.uiButton = go.GetComponent<UIButton>();
|
||||
Util.ResetButton(cb.uiButton);
|
||||
|
||||
var child = go.transform.Find("text");
|
||||
if (child != null)
|
||||
@@ -91,6 +95,8 @@ public class MyCheckButton : MonoBehaviour
|
||||
{
|
||||
cb.labelText.text = "";
|
||||
cb.labelText.fontSize = fontSize;
|
||||
cb.labelText.color = Color.white;
|
||||
cb.labelText.fontStyle = FontStyle.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,30 @@ public class MyCheckBox : MonoBehaviour
|
||||
var go = Instantiate(UIRoot.instance.uiGame.buildMenu.uxFacilityCheck.gameObject);
|
||||
go.name = "my-checkbox";
|
||||
go.SetActive(false);
|
||||
Util.ResetButton(go.GetComponent<UIButton>());
|
||||
var boxImage = go.GetComponent<Image>();
|
||||
if (boxImage)
|
||||
{
|
||||
boxImage.color = BoxColor;
|
||||
boxImage.enabled = true;
|
||||
}
|
||||
var checkImage = go.transform.Find("checked")?.GetComponent<Image>();
|
||||
if (checkImage)
|
||||
{
|
||||
checkImage.color = CheckColor;
|
||||
checkImage.enabled = false;
|
||||
}
|
||||
var comp = go.transform.Find("text");
|
||||
if (comp)
|
||||
{
|
||||
var txt = comp.GetComponent<Text>();
|
||||
if (txt) txt.text = "";
|
||||
if (txt)
|
||||
{
|
||||
txt.text = "";
|
||||
txt.color = TextColor;
|
||||
txt.alignment = TextAnchor.MiddleLeft;
|
||||
txt.fontStyle = FontStyle.Normal;
|
||||
}
|
||||
var localizer = comp.GetComponent<Localizer>();
|
||||
if (localizer) DestroyImmediate(localizer);
|
||||
}
|
||||
@@ -66,6 +85,11 @@ public class MyCheckBox : MonoBehaviour
|
||||
cb.uiButton = go.GetComponent<UIButton>();
|
||||
cb.boxImage = go.transform.GetComponent<Image>();
|
||||
cb.checkImage = go.transform.Find("checked")?.GetComponent<Image>();
|
||||
Util.ResetButton(cb.uiButton);
|
||||
cb.boxImage.color = BoxColor;
|
||||
cb.boxImage.enabled = true;
|
||||
cb.checkImage.color = CheckColor;
|
||||
cb.checkImage.enabled = false;
|
||||
Util.NormalizeRectWithTopLeft(cb.checkImage, 0f, 0f);
|
||||
|
||||
var child = go.transform.Find("text");
|
||||
@@ -76,17 +100,21 @@ public class MyCheckBox : MonoBehaviour
|
||||
{
|
||||
cb.labelText.text = "";
|
||||
cb.labelText.fontSize = fontSize;
|
||||
cb.labelText.color = TextColor;
|
||||
cb.labelText.alignment = TextAnchor.MiddleLeft;
|
||||
cb.labelText.fontStyle = FontStyle.Normal;
|
||||
cb.UpdateLabelTextWidth();
|
||||
}
|
||||
}
|
||||
|
||||
cb.SetEnable(true);
|
||||
cb.uiButton.onClick += cb.OnClick;
|
||||
return cb;
|
||||
}
|
||||
|
||||
private void UpdateLabelTextWidth()
|
||||
{
|
||||
if (labelText) labelText.rectTransform.sizeDelta = new Vector2(labelText.preferredWidth, labelText.rectTransform.sizeDelta.y);
|
||||
if (labelText) labelText.rectTransform.sizeDelta = new Vector2(Util.GetPreferredWidth(labelText), labelText.rectTransform.sizeDelta.y);
|
||||
}
|
||||
|
||||
public bool Checked
|
||||
|
||||
@@ -21,6 +21,10 @@ public class MyComboBox : MonoBehaviour
|
||||
var go = Instantiate(UIRoot.instance.optionWindow.resolutionComp.gameObject);
|
||||
go.name = "my-combobox";
|
||||
go.SetActive(false);
|
||||
foreach (var button in go.GetComponentsInChildren<UIButton>(true))
|
||||
{
|
||||
Util.ResetButton(button);
|
||||
}
|
||||
|
||||
var rect = (RectTransform)go.transform;
|
||||
var cbctrl = rect.GetComponent<UIComboBox>();
|
||||
@@ -38,6 +42,7 @@ public class MyComboBox : MonoBehaviour
|
||||
txtComp.font = fontSource.font;
|
||||
txtComp.fontSize = fontSource.fontSize;
|
||||
txtComp.fontStyle = fontSource.fontStyle;
|
||||
txtComp.color = Color.white;
|
||||
}
|
||||
txtComp = rect.Find("Main Button/Text")?.GetComponent<Text>();
|
||||
if (txtComp)
|
||||
@@ -45,10 +50,22 @@ public class MyComboBox : MonoBehaviour
|
||||
txtComp.font = fontSource.font;
|
||||
txtComp.fontSize = fontSource.fontSize;
|
||||
txtComp.fontStyle = fontSource.fontStyle;
|
||||
txtComp.color = Color.white;
|
||||
}
|
||||
}
|
||||
cbctrl.onSubmit.RemoveAllListeners();
|
||||
cbctrl.onItemIndexChange.RemoveAllListeners();
|
||||
cbctrl.itemIndex = -1;
|
||||
cbctrl.isDroppedDown = false;
|
||||
cbctrl.m_Input.text = "";
|
||||
cbctrl.m_Text.text = "";
|
||||
cbctrl.m_Input.textComponent.color = Color.white;
|
||||
cbctrl.m_Text.color = Color.white;
|
||||
cbctrl.m_DropDownContent.anchoredPosition = Vector2.zero;
|
||||
cbctrl.m_DropDownList.gameObject.SetActive(false);
|
||||
cbctrl.m_EmptyItemRes.gameObject.SetActive(false);
|
||||
cbctrl.m_SelectionBG.gameObject.SetActive(false);
|
||||
cbctrl.m_Scrollbar.gameObject.SetActive(false);
|
||||
_baseObject = go;
|
||||
}
|
||||
|
||||
@@ -58,6 +75,10 @@ public class MyComboBox : MonoBehaviour
|
||||
gameObject.name = "my-combobox";
|
||||
gameObject.SetActive(true);
|
||||
var cb = gameObject.AddComponent<MyComboBox>();
|
||||
foreach (var button in gameObject.GetComponentsInChildren<UIButton>(true))
|
||||
{
|
||||
Util.ResetButton(button);
|
||||
}
|
||||
var rtrans = Util.NormalizeRectWithTopLeft(cb, x, y, parent);
|
||||
cb._rectTrans = rtrans;
|
||||
var box = rtrans.GetComponent<UIComboBox>();
|
||||
@@ -161,4 +182,4 @@ public class MyComboBox : MonoBehaviour
|
||||
|
||||
public float Width => _rectTrans.sizeDelta.x;
|
||||
public float Height => _rectTrans.sizeDelta.y;
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,32 @@ public class MyCornerComboBox : MonoBehaviour
|
||||
var go = Instantiate(UIRoot.instance.uiGame.starDetail.displayCombo.gameObject);
|
||||
go.name = "my-small-combobox";
|
||||
go.SetActive(false);
|
||||
foreach (var button in go.GetComponentsInChildren<UIButton>(true))
|
||||
{
|
||||
Util.ResetButton(button);
|
||||
}
|
||||
|
||||
var cbctrl = go.transform.GetComponent<UIComboBox>();
|
||||
cbctrl.onSubmit.RemoveAllListeners();
|
||||
cbctrl.onItemIndexChange.RemoveAllListeners();
|
||||
cbctrl.itemIndex = -1;
|
||||
cbctrl.isDroppedDown = false;
|
||||
cbctrl.m_Input.text = "";
|
||||
cbctrl.m_Text.text = "";
|
||||
cbctrl.m_Input.textComponent.color = Color.white;
|
||||
cbctrl.m_Text.color = Color.white;
|
||||
cbctrl.m_DropDownContent.anchoredPosition = Vector2.zero;
|
||||
cbctrl.m_DropDownList.gameObject.SetActive(false);
|
||||
cbctrl.m_EmptyItemRes.gameObject.SetActive(false);
|
||||
cbctrl.m_SelectionBG.gameObject.SetActive(false);
|
||||
cbctrl.m_Scrollbar.gameObject.SetActive(false);
|
||||
foreach (var button in cbctrl.ItemButtons)
|
||||
{
|
||||
Destroy(button.gameObject);
|
||||
}
|
||||
cbctrl.Items.Clear();
|
||||
cbctrl.ItemButtons.Clear();
|
||||
cbctrl.m_ListItemRes.GetComponentInChildren<Text>().color = Color.white;
|
||||
_baseObject = go;
|
||||
}
|
||||
|
||||
@@ -40,6 +56,10 @@ public class MyCornerComboBox : MonoBehaviour
|
||||
gameObject.name = "my-combobox";
|
||||
gameObject.SetActive(true);
|
||||
var cb = gameObject.AddComponent<MyCornerComboBox>();
|
||||
foreach (var button in gameObject.GetComponentsInChildren<UIButton>(true))
|
||||
{
|
||||
Util.ResetButton(button);
|
||||
}
|
||||
RectTransform rtrans;
|
||||
if (topRight)
|
||||
{
|
||||
|
||||
@@ -20,18 +20,30 @@ public class MyFlatButton : MonoBehaviour
|
||||
var btn = go.GetComponent<UIButton>();
|
||||
go.GetComponent<Image>().sprite = panel.buttonDefaultSprite;
|
||||
btn.gameObject.name = "my-flatbutton";
|
||||
go.SetActive(false);
|
||||
Util.ResetButton(btn);
|
||||
btn.highlighted = false;
|
||||
var img = btn.GetComponent<Image>();
|
||||
if (img != null)
|
||||
{
|
||||
img.sprite = panel.buttonDefaultSprite;
|
||||
img.color = new Color(img.color.r, img.color.g, img.color.b, 13f / 255f);
|
||||
img.color = new Color(1f, 1f, 1f, 13f / 255f);
|
||||
img.enabled = true;
|
||||
}
|
||||
|
||||
img = btn.gameObject.transform.Find("frame")?.GetComponent<Image>();
|
||||
if (img != null)
|
||||
{
|
||||
img.color = new Color(img.color.r, img.color.g, img.color.b, 0f);
|
||||
img.color = new Color(1f, 1f, 1f, 0f);
|
||||
img.enabled = true;
|
||||
}
|
||||
|
||||
var text = btn.gameObject.transform.Find("Text")?.GetComponent<Text>();
|
||||
if (text)
|
||||
{
|
||||
text.text = "";
|
||||
text.color = Color.white;
|
||||
text.fontStyle = FontStyle.Normal;
|
||||
}
|
||||
|
||||
btn.button.onClick.RemoveAllListeners();
|
||||
@@ -53,6 +65,7 @@ public class MyFlatButton : MonoBehaviour
|
||||
|
||||
cb.rectTrans = rect;
|
||||
cb.uiButton = go.GetComponent<UIButton>();
|
||||
Util.ResetButton(cb.uiButton);
|
||||
|
||||
cb.labelText = go.transform.Find("Text")?.GetComponent<Text>();
|
||||
cb.uiButton.onClick += onClick;
|
||||
|
||||
@@ -60,6 +60,21 @@ public class MyKeyBinder : MonoBehaviour
|
||||
kb.setDefaultUIButton = uikeyEntry.setDefaultUIButton;
|
||||
kb.setNoneKeyUIButton = uikeyEntry.setNoneKeyUIButton;
|
||||
|
||||
Util.ResetButton(kb.inputUIButton);
|
||||
Util.ResetButton(kb.setDefaultUIButton);
|
||||
Util.ResetButton(kb.setNoneKeyUIButton);
|
||||
kb.functionText.text = "";
|
||||
kb.functionText.color = Color.white;
|
||||
kb.functionText.fontStyle = FontStyle.Normal;
|
||||
kb.keyText.text = "";
|
||||
kb.keyText.color = uikeyEntry.builtinColor;
|
||||
kb.keyText.fontStyle = FontStyle.Normal;
|
||||
kb.conflictText.text = "";
|
||||
kb.waitingText.text = "";
|
||||
kb.conflictText.gameObject.SetActive(false);
|
||||
kb.waitingText.gameObject.SetActive(false);
|
||||
kb.setTheKeyToggle.isOn = false;
|
||||
kb.setTheKeyInput.text = "";
|
||||
|
||||
kb.functionText.text = label.Translate();
|
||||
kb.functionText.fontSize = 17;
|
||||
@@ -232,4 +247,4 @@ public class MyKeyBinder : MonoBehaviour
|
||||
{
|
||||
keyText.text = _config.Value.Serialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,10 @@ public class MySideSlider : MonoBehaviour
|
||||
var go = Instantiate(UIRoot.instance.uiGame.stationWindow.maxMiningSpeedGroup.gameObject);
|
||||
//sizeDelta = 240, 20
|
||||
go.name = "my-side-slider";
|
||||
foreach (var button in go.GetComponentsInChildren<UIButton>(true))
|
||||
{
|
||||
Util.ResetButton(button);
|
||||
}
|
||||
Destroy(go.transform.Find("label").gameObject);
|
||||
Destroy(go.GetComponent<UIButton>());
|
||||
go.SetActive(true);
|
||||
@@ -34,6 +38,7 @@ public class MySideSlider : MonoBehaviour
|
||||
sl.slider = go.transform.Find("slider").GetComponent<Slider>();
|
||||
sl.slider.minValue = 0f;
|
||||
sl.slider.maxValue = 100f;
|
||||
sl.slider.interactable = true;
|
||||
sl.slider.onValueChanged.RemoveAllListeners();
|
||||
sl.slider.onValueChanged.AddListener(sl.SliderChanged);
|
||||
if (width == 0) width = 160f;
|
||||
@@ -45,6 +50,9 @@ public class MySideSlider : MonoBehaviour
|
||||
sl.Value = 0f;
|
||||
|
||||
sl.labelText = go.transform.Find("value").GetComponent<Text>();
|
||||
sl.labelText.text = "";
|
||||
sl.labelText.color = Color.white;
|
||||
sl.labelText.fontStyle = FontStyle.Normal;
|
||||
sl.labelText.alignment = textWidth <= 0f ? TextAnchor.MiddleLeft : TextAnchor.MiddleRight;
|
||||
if (sl.labelText.transform is RectTransform rectTrans2)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,10 @@ public class MySlider : MonoBehaviour
|
||||
//sizeDelta = 240, 20
|
||||
go.name = "my-slider";
|
||||
go.SetActive(true);
|
||||
foreach (var button in go.GetComponentsInChildren<UIButton>(true))
|
||||
{
|
||||
Util.ResetButton(button);
|
||||
}
|
||||
var sl = go.AddComponent<MySlider>();
|
||||
var rect = Util.NormalizeRectWithTopLeft(sl, x, y, parent);
|
||||
sl.rectTrans = rect;
|
||||
@@ -40,12 +44,17 @@ public class MySlider : MonoBehaviour
|
||||
sl.slider = go.GetComponent<Slider>();
|
||||
sl.slider.minValue = 0f;
|
||||
sl.slider.maxValue = 100f;
|
||||
sl.slider.interactable = true;
|
||||
sl.slider.onValueChanged.RemoveAllListeners();
|
||||
sl.slider.onValueChanged.AddListener(sl.SliderChanged);
|
||||
sl.Value = 0f;
|
||||
sl.labelText = sl.slider.handleRect.Find("Text")?.GetComponent<Text>();
|
||||
if (sl.labelText)
|
||||
{
|
||||
sl.labelText.text = "";
|
||||
sl.labelText.color = Color.white;
|
||||
sl.labelText.alignment = TextAnchor.MiddleCenter;
|
||||
sl.labelText.fontStyle = FontStyle.Normal;
|
||||
sl.labelText.fontSize = 14;
|
||||
if (sl.labelText.transform is RectTransform rectTrans)
|
||||
{
|
||||
@@ -60,11 +69,13 @@ public class MySlider : MonoBehaviour
|
||||
if (bg != null)
|
||||
{
|
||||
bg.color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
|
||||
bg.enabled = true;
|
||||
}
|
||||
var fill = sl.slider.fillRect.GetComponent<Image>();
|
||||
if (fill != null)
|
||||
{
|
||||
fill.color = new Color(1f, 1f, 1f, 0.28f);
|
||||
fill.enabled = true;
|
||||
}
|
||||
sl.UpdateLabel();
|
||||
|
||||
|
||||
+21
-1
@@ -48,6 +48,7 @@ public class MyWindow : ManualBehaviour
|
||||
var go = Instantiate(_baseObject, UIRoot.instance.uiGame.transform.parent);
|
||||
go.name = name;
|
||||
go.SetActive(false);
|
||||
Util.ResetButton(go.transform.Find("panel-bg")?.GetComponentInChildren<UIButton>());
|
||||
MyWindow win = go.AddComponent<T>();
|
||||
if (!win) return null;
|
||||
|
||||
@@ -385,9 +386,13 @@ public class MyWindow : ManualBehaviour
|
||||
inputField.gameObject.name = objName;
|
||||
Destroy(inputField.GetComponent<UIButton>());
|
||||
inputField.GetComponent<Image>().color = new Color(1f, 1f, 1f, 0.05f);
|
||||
inputField.GetComponent<Image>().enabled = true;
|
||||
inputField.interactable = true;
|
||||
var rect = Util.NormalizeRectWithTopLeft(inputField, x, y, parent);
|
||||
rect.sizeDelta = new Vector2(210, rect.sizeDelta.y);
|
||||
inputField.text = text;
|
||||
inputField.textComponent.color = Color.white;
|
||||
inputField.textComponent.fontStyle = FontStyle.Normal;
|
||||
inputField.textComponent.fontSize = fontSize;
|
||||
|
||||
inputField.onValueChanged.RemoveAllListeners();
|
||||
@@ -408,9 +413,13 @@ public class MyWindow : ManualBehaviour
|
||||
inputField.gameObject.name = objName;
|
||||
Destroy(inputField.GetComponent<UIButton>());
|
||||
inputField.GetComponent<Image>().color = new Color(1f, 1f, 1f, 0.05f);
|
||||
inputField.GetComponent<Image>().enabled = true;
|
||||
inputField.interactable = true;
|
||||
var rect = Util.NormalizeRectWithTopLeft(inputField, x, y, parent);
|
||||
rect.sizeDelta = new Vector2(width, rect.sizeDelta.y);
|
||||
inputField.text = config.Value;
|
||||
inputField.textComponent.color = Color.white;
|
||||
inputField.textComponent.fontStyle = FontStyle.Normal;
|
||||
inputField.textComponent.fontSize = fontSize;
|
||||
|
||||
inputField.onValueChanged.RemoveAllListeners();
|
||||
@@ -447,7 +456,10 @@ public class MyWindowWithTabs : MyWindow
|
||||
var swarmPanel = UIRoot.instance.uiGame.dysonEditor.controlPanel.hierarchy.swarmPanel;
|
||||
var src = swarmPanel.orbitButtons[0];
|
||||
var btn = Instantiate(src);
|
||||
Util.ResetButton(btn);
|
||||
btn.gameObject.GetComponent<Image>().sprite = swarmPanel.buttonDefaultSprite;
|
||||
btn.gameObject.GetComponent<Image>().color = Color.white;
|
||||
btn.gameObject.GetComponent<Image>().enabled = true;
|
||||
btn.name = "tab-btn-" + index;
|
||||
btn.highlighted = false;
|
||||
|
||||
@@ -468,7 +480,9 @@ public class MyWindowWithTabs : MyWindow
|
||||
shadow.effectColor = new Color(0f, 0f, 0f, 0.4f);
|
||||
shadow.effectDistance = new Vector2(1f, -1f);
|
||||
btnText.text = label.Translate();
|
||||
btnText.color = Color.white;
|
||||
btnText.fontSize = 16;
|
||||
btnText.fontStyle = FontStyle.Normal;
|
||||
btn.data = index;
|
||||
|
||||
_tabGroup.AddTab(tabRect, btn);
|
||||
@@ -488,6 +502,12 @@ public class MyWindowWithTabs : MyWindow
|
||||
public void AddSplitter(RectTransform parent, float spacing)
|
||||
{
|
||||
var img = Instantiate(UIRoot.instance.optionWindow.transform.Find("tab-line").Find("bar"));
|
||||
var image = img.GetComponent<Image>();
|
||||
if (image)
|
||||
{
|
||||
image.color = Color.white;
|
||||
image.enabled = true;
|
||||
}
|
||||
Destroy(img.Find("tri").gameObject);
|
||||
_tabY += spacing;
|
||||
var rect = Util.NormalizeRectWithTopLeft(img, 28, _tabY, parent);
|
||||
@@ -633,4 +653,4 @@ public abstract class MyWindowManager
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,34 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UXAssist.UI;
|
||||
|
||||
public static class Util
|
||||
{
|
||||
|
||||
public static float GetPreferredWidth(Text text)
|
||||
{
|
||||
// DSP caches preferred sizes in its custom text generator, separately from Unity's layout queue.
|
||||
text.SetLayoutDirty();
|
||||
return text.preferredWidth;
|
||||
}
|
||||
|
||||
public static void ResetButton(UIButton button)
|
||||
{
|
||||
if (!button) return;
|
||||
button.enabled = true;
|
||||
button.highlighted = false;
|
||||
button.updating = true;
|
||||
button.data = 0;
|
||||
button.tips = default;
|
||||
if (button.button)
|
||||
{
|
||||
button.button.enabled = true;
|
||||
button.button.interactable = true;
|
||||
}
|
||||
button.MReset();
|
||||
}
|
||||
|
||||
public static RectTransform NormalizeRectWithTopLeft(Component cmp, float left, float top, Transform parent = null)
|
||||
{
|
||||
if (cmp.transform is not RectTransform rect) return null;
|
||||
|
||||
Reference in new issue
Block a user