73 lines
2.1 KiB
C#
Raw Normal View History

2025-04-09 13:17:42 +08:00
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using TMPro;
2025-04-23 10:33:15 +08:00
using static OperationController;
2025-04-09 13:17:42 +08:00
namespace QFramework.Example
{
public class UIChangeOperationData : UIPanelData
{
}
public partial class UIChangeOperation : UIPanel
{
Color selectedColor = new Color(255f / 255f, 248f / 255f, 29f / 255f);
Button curBtn;
protected override void OnInit(IUIData uiData = null)
{
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuit).UnRegisterWhenGameObjectDestroyed(gameObject);
2025-04-23 10:33:15 +08:00
2025-04-09 13:17:42 +08:00
mData = uiData as UIChangeOperationData ?? new UIChangeOperationData();
// please add init code here
for (int i = 0; i < Content.childCount; i++)
{
Transform transform = Content.GetChild(i);
TextMeshProUGUI text = transform.Find("Label").GetComponent<TextMeshProUGUI>();
Button btn = transform.GetComponent<Button>();
btn.onClick.AddListener(() =>
{
if (curBtn != btn)
{
if (curBtn != null)
{
curBtn.transform.Find("Label").GetComponent<TextMeshProUGUI>().color = Color.white;
}
StringEventSystem.Global.Send("OperationChange" + transform.name);
text.color = selectedColor;
curBtn = btn;
}
});
}
curBtn = Content.GetChild(0).GetComponent<Button>();
}
protected override void OnOpen(IUIData uiData = null)
{
}
2025-04-23 15:38:01 +08:00
2025-04-09 13:17:42 +08:00
protected override void OnShow()
{
}
protected override void OnHide()
{
2025-04-23 10:33:15 +08:00
2025-04-09 13:17:42 +08:00
}
2025-04-23 15:38:01 +08:00
private void OnDisable()
2025-04-09 13:17:42 +08:00
{
2025-04-23 15:38:01 +08:00
2025-04-23 10:33:15 +08:00
}
2025-04-23 15:38:01 +08:00
protected override void OnClose()
2025-04-23 10:33:15 +08:00
{
2025-04-23 15:38:01 +08:00
//transform.gameObject.SetActive(false);
2025-04-09 13:17:42 +08:00
}
public void OnModuleQuit(OnModuleQuit arg)
{
Hide();
}
2025-04-09 13:17:42 +08:00
}
}