修改搜索菜单样式

This commit is contained in:
shenjianxing 2025-04-14 11:23:20 +08:00
parent f66df0aab2
commit 4d23f8cd3a

View File

@ -349,34 +349,26 @@ namespace QFramework.Example
GameObject clone = GameObject.Instantiate(SearchItem.gameObject, SearchContent); GameObject clone = GameObject.Instantiate(SearchItem.gameObject, SearchContent);
searchItemMap.Add(clone, child.gameObject); searchItemMap.Add(clone, child.gameObject);
Transform subContent = child.Find("SubContent"); Transform subContent = child.Find("SubContent");
if (subContent.childCount > 0)
{
Button btn = clone.transform.Find("Button").GetComponent<Button>(); Button btn = clone.transform.Find("Button").GetComponent<Button>();
btn.onClick.AddListener(() => btn.onClick.AddListener(() =>
{ {
child.Find("Content/Toggle/Obj").GetComponent<Toggle>().isOn = true; child.Find("Content/Toggle/Obj").GetComponent<Button>().onClick.Invoke();
}); });
string grou = string.Empty;
if (subContent.childCount > 0)
{
grou = "(组)";
CheckChildren(subContent, str);
}
Transform buttonLabel = btn.transform.Find("Label"); Transform buttonLabel = btn.transform.Find("Label");
if (buttonLabel != null) if (buttonLabel != null)
{ {
TextMeshProUGUI buttonText = buttonLabel.GetComponent<TextMeshProUGUI>(); TextMeshProUGUI buttonText = buttonLabel.GetComponent<TextMeshProUGUI>();
if (buttonText != null) if (buttonText != null)
{ {
buttonText.text = "组" + name + ">"; buttonText.text = grou + name + ">";
}
}
CheckChildren(subContent, str);
}
else
{
Transform buttonLabel = clone.transform.Find("Button/Label");
if (buttonLabel != null)
{
TextMeshProUGUI buttonText = buttonLabel.GetComponent<TextMeshProUGUI>();
if (buttonText != null)
{
buttonText.text = name + ">";
}
} }
} }
} }