登录和输入控件

This commit is contained in:
2025-08-20 23:57:22 +08:00
parent 818bf63d8d
commit 2f8251fe63
28 changed files with 346 additions and 70 deletions

View File

@@ -12,6 +12,7 @@ namespace NBF
UIObjectFactory.SetPackageItemExtension(SelectPages.URL, typeof(SelectPages));
UIObjectFactory.SetPackageItemExtension(ModelTexture.URL, typeof(ModelTexture));
UIObjectFactory.SetPackageItemExtension(BottomMenu.URL, typeof(BottomMenu));
UIObjectFactory.SetPackageItemExtension(CommonInput.URL, typeof(CommonInput));
UIObjectFactory.SetPackageItemExtension(ClassifyList.URL, typeof(ClassifyList));
UIObjectFactory.SetPackageItemExtension(CommonMenu.URL, typeof(CommonMenu));
UIObjectFactory.SetPackageItemExtension(MarqueeTag.URL, typeof(MarqueeTag));

View File

@@ -0,0 +1,29 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class CommonInput
{
public const string URL = "ui://6hgkvlau9zboma";
public Controller FocusState;
public GTextInput Input;
public GImage bottomBack;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
FocusState = GetController("FocusState");
Input = (GTextInput)GetChild("Input");
bottomBack = (GImage)GetChild("bottomBack");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fb776407f4f25e64a8e803ba135bddef

View File

@@ -0,0 +1,47 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class CommonInput : GComponent
{
public EventListener onChanged => Input.onChanged;
public override string text
{
get => Input.text;
set => Input.text = value;
}
public string title
{
get => text;
set => text = value;
}
public string promptText
{
get => Input.promptText;
set => Input.promptText = value;
}
private void OnInited()
{
onFocusIn.Add(OnInputFocusIn);
onFocusOut.Add(OnInputFocusOut);
}
private void OnInputFocusIn()
{
FocusState.selectedIndex = 1;
}
private void OnInputFocusOut()
{
FocusState.selectedIndex = 0;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c7adc7972d1d401489dc796fb27d1eaa

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 12482424a8714a5fb52ce23312a0a0f6
timeCreated: 1755697902

View File

@@ -0,0 +1,54 @@
using Assets.Scripts.Entity;
using Assets.Scripts.Hotfix;
using NBC;
using NBC.Network;
namespace NBF
{
public static class LoginHelper
{
private static Session _session;
public static async FTask Login(string account)
{
_session = Net.CreateSession("127.0.0.1:20001");
var acc = account;
// 发送登录的请求给服务器
var response = (A2C_LoginResponse)await Net.Call(new C2A_LoginRequest()
{
Username = acc,
Password = acc,
LoginType = 1
});
if (response.ErrorCode != 0)
{
Log.Error($"登录发生错误{response.ErrorCode}");
return;
}
if (!App.Main.GetComponent<JWTParseComponent>().Parse(response.ToKen, out var payload))
{
return;
}
// 根据ToKen返回的Address登录到Gate服务器
_session = Net.CreateSession(payload.Address);
// 发送登录请求到Gate服务器
var loginResponse = (G2C_LoginResponse)await Net.Call(new C2G_LoginRequest()
{
ToKen = response.ToKen
});
if (loginResponse.ErrorCode != 0)
{
Log.Error($"登录发生错误{loginResponse.ErrorCode}");
return;
}
Log.Debug($"登录到Gate服务器成功ErrorCode:{loginResponse.ErrorCode}");
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 031ed023449844cdb9d6c4eb5d7fee90
timeCreated: 1755698636

View File

@@ -0,0 +1,32 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
using System.Collections.Generic;
namespace NBF
{
/// <summary> </summary>
public partial class LoginPanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
public override string UIPackName => "Main";
public override string UIResName => "LoginPanel";
[AutoFind(Name = "Back")]
public GLabel Back;
[AutoFind(Name = "InputAccount")]
public CommonInput InputAccount;
[AutoFind(Name = "BtnLogin")]
public GButton BtnLogin;
public override string[] GetDependPackages(){ return new string[] {"Common"}; }
public static void Show(object param = null){ App.UI.OpenUI<LoginPanel>(param); }
public static void Hide(){ App.UI.HideUI<LoginPanel>(); }
public static void Del(){ App.UI.DestroyUI<LoginPanel>(); }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3b11ed3a4a10a3549a06d7845c9c4cfd

View File

@@ -0,0 +1,25 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using FairyGUI;
using UnityEngine;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class LoginPanel : UIPanel
{
protected override void OnInit()
{
this.AutoAddClick(OnClick);
}
private void OnClick(GComponent btn)
{
if (btn == BtnLogin)
{
LoginHelper.Login(InputAccount.text).Coroutine();
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b2d32e54ef5680541959b782ee8d0c7a