Cute_demon_attacks/meng_yao/Assets/script/scene_Main/ReviseName.cs

69 lines
2.5 KiB
C#

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<BoxType> boxTypes = new List<BoxType>();
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<RectTransform>();
rect.transform.position = new Vector3(Screen.width/2,Screen.height/2,0);
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "修改昵称");//测试输入框回调处理
gameObjects[1].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
{
if (type == 0)//取消
{
gameObject.GetComponent<input_box_pop_up_window>().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<HeadTanchuang>().UpdateShow();
gameObject.GetComponent<input_box_pop_up_window>().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);
}
}