更新UI组件命名规范:变量名与组件名保持一致
This commit is contained in:
@@ -7,15 +7,20 @@
|
||||
```csharp
|
||||
public class LoginWindow : AbsHFUIWindow
|
||||
{
|
||||
[SerializeField] private SFUI_Button btn_Login;
|
||||
private SFUI_Button BtnLogin;
|
||||
|
||||
protected override void OnRunAwake()
|
||||
{
|
||||
base.OnRunAwake();
|
||||
// OnRunAwake: 初始化组件引用和按钮事件绑定(仅调用一次)
|
||||
btn_Login.OnAddClickListener += OnBtnLogin;
|
||||
btn_Login.OnAddEnterListener += OnBtnEnter;
|
||||
btn_Login.OnAddExitListener += OnBtnExit;
|
||||
BtnLogin = FindUICtrlByName<SFUI_Button>("BtnLogin");
|
||||
|
||||
if (BtnLogin != null)
|
||||
{
|
||||
BtnLogin.OnAddClickListener += OnBtnLoginClick;
|
||||
BtnLogin.OnAddEnterListener += OnBtnLoginEnter;
|
||||
BtnLogin.OnAddExitListener += OnBtnLoginExit;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpen(Action _onOpenComplete)
|
||||
@@ -28,13 +33,21 @@ public class LoginWindow : AbsHFUIWindow
|
||||
|
||||
protected override void OnClose(Action _onCloseComplete)
|
||||
{
|
||||
base.OnClose(_onCloseComplete);
|
||||
// OnClose: 移除CTC事件监听(每次关闭调用)
|
||||
// OnClose: 移除事件监听(每次关闭调用)
|
||||
if (BtnLogin != null)
|
||||
{
|
||||
BtnLogin.OnAddClickListener -= OnBtnLoginClick;
|
||||
BtnLogin.OnAddEnterListener -= OnBtnLoginEnter;
|
||||
BtnLogin.OnAddExitListener -= OnBtnLoginExit;
|
||||
}
|
||||
|
||||
HFFunCatalogue.Event.CTCEvent.RemoveListener<HFEvent_CTC_LoginResult>(
|
||||
enHFCTCEvent.LoginResult, OnLoginResult);
|
||||
|
||||
base.OnClose(_onCloseComplete);
|
||||
}
|
||||
|
||||
void OnBtnLogin(GameObject go)
|
||||
void OnBtnLoginClick(GameObject go)
|
||||
{
|
||||
// 处理登录逻辑 - 使用框架标准调用方式
|
||||
HFEvent_CTC_Login evt = HFFunCatalogue.New<HFEvent_CTC_Login>();
|
||||
@@ -43,12 +56,12 @@ public class LoginWindow : AbsHFUIWindow
|
||||
evt.Dispatch();
|
||||
}
|
||||
|
||||
void OnBtnEnter(GameObject go)
|
||||
void OnBtnLoginEnter(GameObject go)
|
||||
{
|
||||
// 鼠标进入
|
||||
}
|
||||
|
||||
void OnBtnExit(GameObject go)
|
||||
void OnBtnLoginExit(GameObject go)
|
||||
{
|
||||
// 鼠标退出
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user