80 lines
1.9 KiB
C#
80 lines
1.9 KiB
C#
using Framework;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
public class UIGiftCodeAwardsController: UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
private Button mSureBtn;
|
|
private Button mCloseBtn;
|
|
private ItemCounts mItems;
|
|
|
|
|
|
///Auto Gen End///
|
|
|
|
// Use this for initialization
|
|
public override void OnAwake()
|
|
{
|
|
//bind UI GameObj
|
|
mSureBtn= GetComponent<Button>("bg/SureBtn");
|
|
mCloseBtn = GetComponent<Button>("ReturnBtn");
|
|
BindButton(mSureBtn, OnSureBtnClose);
|
|
BindButton(mCloseBtn, OnReturnBtnClose);
|
|
|
|
}
|
|
|
|
private void OnReturnBtnClose()
|
|
{
|
|
CloseWindow();
|
|
}
|
|
|
|
private void OnSureBtnClose()
|
|
{
|
|
CloseWindow();
|
|
}
|
|
|
|
//invoke when open window
|
|
protected override void OnOpenWindow(object data = null)
|
|
{
|
|
|
|
mItems=data as ItemCounts;
|
|
RefreshMaterial(mItems);
|
|
|
|
}
|
|
|
|
private void RefreshMaterial(ItemCounts mItems)
|
|
{
|
|
string allName = "";
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
GameObject itemParent = FindObj(string.Format("UI_Materals/{0}", (i + 1).ToString()));
|
|
Utils.CommonUtils.DestoryAllChildGameObject(Utils.CommonUtils.GetGameObject(itemParent, "item"));
|
|
|
|
if ((i + 1) <= mItems.Ids.Count)
|
|
{
|
|
itemParent.SetActive(true);
|
|
|
|
ItemObj itemObj = new ItemObj((int)mItems.Ids[i], Utils.CommonUtils.GetGameObject(itemParent, "item"));
|
|
Utils.CommonUtils.GetComponent<TMP_Text>(itemParent, "value").text = mItems.Counts[i].ToString();
|
|
allName += TableManager.Instance.Tables.Item.Get((int)mItems.Ids[i]).ID+"X"+ mItems.Counts[i];
|
|
}
|
|
else
|
|
{
|
|
itemParent.SetActive(false);
|
|
}
|
|
}
|
|
GetComponent<TMP_Text>("Text_AwardsText").text = allName;
|
|
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
}
|