thewar_client/Client/Assets/1_Script/GameUI/ShopUiCtrl.cs

44 lines
1.3 KiB
C#

using System.Collections.Generic;
using UnityEngine;
public class ShopUiCtrl : SingletonMonoBehaviour<ShopUiCtrl>
{
[SerializeField] GameObject itemPrefab;
[SerializeField] Transform itemContent;
[SerializeField] GameObject[] shopInfo;
[SerializeField] Transform shopInfoContent;
List<ShopMenuItem> onItemPrefabList;
protected override void OnAwake()
{
onItemPrefabList = new List<ShopMenuItem>();
}
private void OnEnable()
{
Dictionary<long, ShopData> shopDatas = Statics.excelDatas.shopData;
if(shopDatas.Count != onItemPrefabList.Count)
{
foreach (var item in shopDatas)
{
ShopMenuItem shopMenuItem = Instantiate(itemPrefab, itemContent).GetComponent<ShopMenuItem>();
GameObject type = Instantiate(shopInfo[item.Value.image_type == eImageType.bigImage ? 0 : 1], shopInfoContent);
shopMenuItem.Set(item.Value, type);
shopMenuItem.gameObject.SetActive(true);
onItemPrefabList.Add(shopMenuItem);
}
if (onItemPrefabList.Count != 0)
onItemPrefabList[0].SelectButton();
}
}
public void SelectShopMenu()
{
for(int n = 0; n < onItemPrefabList.Count; n++)
{
onItemPrefabList[n].ChangeButton();
}
}
}