using System.Collections; using System.Collections.Generic; using System.Net.NetworkInformation; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class Logo_in : mount { public Slider sceneslider; public Button logo_inbtn; public float loadSpeed = 0.5f; // 填充速度 private float progress = 0f; private bool isLoading = false; public override void Awake() { } // Start is called before the first frame update void Start() { //sceneslider.gameObject.SetActive(false); //logo_inbtn.onClick.AddListener(ShowLogoin); if (sceneslider != null) { sceneslider.value = 0f; // 初始值设为0 } login_in_screen(); } public void login_in_screen()//登录界面 { List boxTypes = new List(); boxTypes.Add(new BoxType { Name = "account_number", textName = " 手机号", prompt = "请输入手机号", Type = 1, is_required = true }); boxTypes.Add(new BoxType { Name = "verification_code", textName = " 验证码", prompt = "请输入验证码", Type = 0, is_required = true }); boxTypes.Add(new BoxType { Name = "submit", textName = " 取消确定 ", Type = 5 }); GameObject gameObject = add_pop_up(true);//生成弹窗母体 List gameObjects = gameObject.GetComponent().updateUI(boxTypes, "登录");//测试输入框回调处理 //gameObjects[0].GetComponent().register_click((BoxType boxType, int type) =>//手机号获取验证码点击 //{ // if (boxType.is_required && string.IsNullOrWhiteSpace(boxType.content)) // { // Promptmgr.Instance.PromptBubble("请不要" + boxType.textName + "为空"); // return; // } // Debug.Log("获取验证码"); //}); gameObjects[2].GetComponent().register_click(async (BoxType boxType, int type) =>//登录确定或取消 { if (type == 0)//注册 { Login login = new Login(); login.Phone = boxTypes[0].content; //register.Code = boxTypes[0].content; string jsonString = JsonUtility.ToJson(login); string response = await web.SendRequest(web.URL+"/Player/Register", "POST", jsonString); Debug.Log(response); } else if (type == 1)//登录 { Login login = new Login(); login.Phone = boxTypes[0].content; Debug.Log(boxTypes[0].content); //register.Code = boxTypes[0].content; string jsonString = JsonUtility.ToJson(login); string response = await web.SendRequest(web.URL+"/Player/Login", "POST", jsonString); Debug.Log(response); Rootobject root = JsonUtility.FromJson(response); if (root.ErrorMessage=="" && boxTypes[0].content!= "") { gameObject.SetActive(false); Promptmgr.Instance.PromptBubble("登录成功"); isLoading = true; } else { Promptmgr.Instance.PromptBubble("登录失败,请先注册"); } } }); } // Update is called once per frame void Update() { // 模拟进度条填充,可以改为你的实际加载逻辑 if (isLoading && progress < 1f) { progress += loadSpeed * Time.deltaTime; sceneslider.value = progress; } // 当进度条填满后,进行场景跳转 if (progress >= 1f && isLoading) { LoadNextScene(); } } private void LoadNextScene() { // 这里使用场景管理器进行跳转 SceneManager.LoadScene(JumpScene.main_scene); } } public class Rootobject { public int ErrorCode; public string ErrorMessage; } public class JsonParser { public static Rootobject ParseJson(string json) { return JsonUtility.FromJson(json); } }