Cute_demon_attacks/meng_yao/Assets/script/ConnactServer/InitInfo.cs
2024-11-01 00:27:45 +08:00

103 lines
2.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Hardware;
using UnityEditorInternal.VersionControl;
using UnityEngine;
using UnityEngine.UI;
public class InitInfo : MonoBehaviour
{
private MainObject parsedData;
private Username userdata;
public Text name;
// Start is called before the first frame update
private async void Start()
{
string response = await web.SendRequest("http://47.109.133.52/Player/GetInfo", "POST");
Debug.Log(response);
parsedData = JsonUtility.FromJson<MainObject>(response);
Debug.Log(parsedData.Info.Gold);
AssestPanel.instance.SetCoinText(parsedData.Info.Gold);
AssestPanel.instance.SetStoneText(parsedData.Info.Gem);
GetListByPhone getlistbyphone = new GetListByPhone();
getlistbyphone.Phone = "1";
string jsonString = JsonUtility.ToJson(getlistbyphone);
string userponse = await web.SendRequest("http://47.109.133.52/Player/GetListByPhone", "POST", jsonString);
Debug.Log(userponse);
<<<<<<< .mine
//RootData RootData = LitJson.JsonMapper.ToObject<RootData>(userponse
RootData itemList = JsonUtility.FromJson<RootData>(userponse);
Debug.Log(itemList.List[0].Gold);
if (itemList.List == null)
{
Debug.Log("list¿Õ");
//Debug.Log(rootData.);
}
=======
userdata = JsonUtility.FromJson<Username>(userponse);
Debug.Log(userdata.ErrorCode);
>>>>>>> .theirs
//name.text=userdata.nameitem.Name;
}
// Update is called once per frame
void Update()
{
}
}
public class MainObject
{
public Info Info;
public int ErrorCode;
public string ErrorMessage;
}
[Serializable]
public class Info
{
public string Id;
public int Gold;
public int Gem;
public string Phone;
public string Name;
}
public class Username
{
public List<nameitem> namelist;
public int ErrorCode;
public string ErrorMessage;
}
public class nameitem
{
public string Id;
public string Phone;
public string Name;
}