73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using QFramework;
|
|
using TMPro;
|
|
using static OperationController;
|
|
|
|
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);
|
|
|
|
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)
|
|
{
|
|
}
|
|
|
|
|
|
protected override void OnShow()
|
|
{
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
|
|
|
|
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
|
|
}
|
|
protected override void OnClose()
|
|
{
|
|
//transform.gameObject.SetActive(false);
|
|
}
|
|
//public void OnModuleQuit(OnModuleQuit arg)
|
|
//{
|
|
// Hide();
|
|
//}
|
|
}
|
|
}
|