using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ReviseName : mount { public Button ReviseBtn; public Text NameText; public Text IdText; public Text island; public GameObject headTanchuang; // Start is called before the first frame update void Start() { ReviseBtn.onClick.AddListener(ReviseClick); } public void ReviseClick() { List boxTypes = new List(); boxTypes.Add(new BoxType { Name = "verification_code", textName = " 修改昵称:", prompt = "请输入修改的昵称", Type = 0, is_required = true }); boxTypes.Add(new BoxType { Name = "submit", textName = " 取消确定 ", prompt = "取消", Type = 2 }); GameObject gameObject = add_pop_up(true);//生成弹窗母体 RectTransform rect = gameObject.GetComponent(); rect.transform.position = new Vector3(Screen.width/2,Screen.height/2,0); List gameObjects = gameObject.GetComponent().updateUI(boxTypes, "修改昵称");//测试输入框回调处理 gameObjects[1].GetComponent().register_click(async (BoxType boxType, int type) =>//登录确定或取消 { if (type == 0)//取消 { gameObject.GetComponent().destroy(); } else if (type == 1)//提交 { Debug.Log(boxTypes[0].content); UpdatePlayerInfoResponse issuccefful = await Scene_main_jiekou.instance.UpdatePlayerInfos("nickname", boxTypes[0].content); if (issuccefful.code ==200) { Promptmgr.Instance.PromptBubble("修改昵称成功"); NameText.text = issuccefful.data.nickname; //IdText.text = issuccefful.data.nickname; headTanchuang.GetComponent().UpdateShow(); gameObject.GetComponent().destroy(); } else { Promptmgr.Instance.PromptBubble(issuccefful.message); } } }); } public async void UpdateShow() { PlayerInfoData info = await Scene_main_jiekou.instance.PlayerInfos(); this.NameText.text = info.nickname.ToString(); this.IdText.text = info.uid.ToString(); island.text = "出生地:"+info.island_name; this.gameObject.SetActive(true); } }