// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖 using System.Collections.Generic; using FairyGUI; using UnityEngine; using NBC; using UIPanel = NBC.UIPanel; namespace NBF { public partial class LoginPanel : UIPanel { private string serverUrl; private string serverPassword; private bool autoLogin = true; protected override void OnInit() { this.AutoAddClick(OnClick); } protected override void OnShowed() { InputServer.Input.promptText = "请输入服务器地址"; InputPass.Input.promptText = "请输入服务器密码"; serverUrl = PlayerPrefs.GetString("serverUrl", string.Empty); serverPassword = PlayerPrefs.GetString("serverPassword", string.Empty); InputServer.Input.text = serverUrl; InputPass.Input.text = serverPassword; if (!string.IsNullOrEmpty(serverUrl) && !string.IsNullOrEmpty(serverPassword)) { if (autoLogin) Connect(); } } private void OnClick(GComponent btn) { if (btn == BtnLogin) { if (!string.IsNullOrEmpty(InputPass.Input.text)) { serverPassword = InputPass.Input.text; } if (!string.IsNullOrEmpty(InputServer.Input.text)) { serverUrl = InputServer.Input.text; } Connect(); // Notices.Show("测试========----------的首发式地方"); // MessageBox.ShowMessage("啊撒旦立刻就了",(b => // { // Log.Info($"b={b}"); // })); } } private void Connect() { Net.Instance.SetServer(serverUrl, serverPassword); PlayerPrefs.SetString("serverUrl", serverUrl); PlayerPrefs.SetString("serverPassword", serverPassword); // PlayerPanel.Show(); autoLogin = false; Net.Instance.Tick(0, 0, 0, (ret) => { if (ret.Code == 0) { // PlayerPanel.Show(); VideoEditorPanel.Show(); } else { MessageBox.ShowMessage("无法连接服务器,请检查服务器信息\n格式:192.168.0.120:9888", null); } }); } } }