_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Address/AddressPanel.cs
2024-11-27 22:38:52 +08:00

46 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AddressPanel : MonoBehaviour
{
public GameObject addressPrefab;
public Transform trans;
public GameObject newAdPanelPrefab;
public Transform tran;
public Button newAddressBtn;
void Start()
{
getData();
newAddressBtn.onClick.AddListener(NewAddress);
}
public void NewAddress()
{
GameObject.Instantiate(newAdPanelPrefab, tran);
}
public async void getData()
{
AdressResponse adressResponse = new AdressResponse();
AdressList83 adressList83 = new AdressList83();
adressResponse = await adressList83.AdressList();
int length = adressResponse.data.Count;
for (int i = 0; i < length; i++)
{
//Debug.Log(i);
GameObject addres = GameObject.Instantiate(addressPrefab, trans);
addres.name = "address_" + i;
addressItem item = addres.GetComponent<addressItem>();
Address address = adressResponse.data[i];
item.SetInfo(address);
}
}
}