_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/lianghaoLL/BagPanel.cs

70 lines
1.9 KiB
C#
Raw Normal View History

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BagPanel : MonoBehaviour
{
public GameObject woniuConnect;
public GameObject wokeConnect;
public GameObject woniuSc;
public GameObject wokeSc;
public Button woniuBtn;
public Button wokeBtn;
public GameObject Musk;
// Start is called before the first frame update
void Start()
{
woniuBtn.onClick.AddListener(WoniuClick);
wokeBtn.onClick.AddListener(WokeClick);
Init();
}
async void Init()
{
string response = "";//<2F><><EFBFBD><EFBFBD>
response = await web.SendRequest(web.URL + "/snail/user/queryUserBag", "POST","{}", Global.global.CreateHeaders());
Debug.Log(response);
ServerRespon111 serverRespon111 = JsonConvert.DeserializeObject<ServerRespon111>(response);
for (int i = 0; i < serverRespon111.snailCount; i++)
{
GameObject woniuitem = (GameObject)Instantiate(Resources.Load("LLPrefabs/items"),woniuConnect.transform);
}
for (int i = 0; i < serverRespon111.slotCount; i++)
{
GameObject wokeitem = (GameObject)Instantiate(Resources.Load("LLPrefabs/items"),wokeConnect.transform);
}
wokeSc.gameObject.SetActive(false);
}
void WoniuClick()
{
woniuBtn.transform.SetParent(this.transform);
wokeBtn.transform.SetParent(Musk.transform);
woniuSc.gameObject.SetActive(true);
wokeSc.gameObject.SetActive(false);
}
void WokeClick()
{
woniuBtn.transform.SetParent(Musk.transform);
wokeBtn.transform.SetParent(this.transform);
woniuSc.gameObject.SetActive(false);
wokeSc.gameObject.SetActive(true);
}
// Update is called once per frame
void Update()
{
}
}