每日自动提交 2026-04-17 18:30
This commit is contained in:
@@ -4,6 +4,7 @@ using Assets.MyGame.Scripts.Net.API.UserData_SubClass;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -14,13 +15,10 @@ public class UIHome_BY_BackPackPanel : SubUIBase
|
||||
public Dictionary<int,BaseProductCount> propsObjHashCode_Dic = new Dictionary<int, BaseProductCount>();
|
||||
public Transform pageParent;
|
||||
public GameObject prefabItem;
|
||||
public GameObject prefabPage;
|
||||
|
||||
public TextMeshProUGUI tMP_Name;
|
||||
public TextMeshProUGUI tMP_Description;
|
||||
|
||||
public Button btn_Next;
|
||||
public Button btn_Up;
|
||||
public TextMeshProUGUI text_PageNum;
|
||||
public int pageCountNum = 0;
|
||||
public int pageNum = 1;
|
||||
@@ -39,23 +37,22 @@ public class UIHome_BY_BackPackPanel : SubUIBase
|
||||
propsID_Dic[product.number]=product;
|
||||
if (product.count<=0)
|
||||
{
|
||||
|
||||
propsID_Dic.Remove(product.number);
|
||||
}
|
||||
}
|
||||
for (int j = pageParent.childCount-1; j >=0 ; j--)
|
||||
{
|
||||
Destroy(pageParent.GetChild(j).gameObject);
|
||||
}
|
||||
int i=0;
|
||||
|
||||
Transform itemParent=null;
|
||||
itemParent = Instantiate(prefabPage, pageParent).transform;
|
||||
|
||||
pageCountNum++;
|
||||
foreach (BaseProductCount product in propsID_Dic.Values)
|
||||
{
|
||||
if (propsID_Dic.Count %12 == 0&&propsID_Dic.Count!=0)
|
||||
{
|
||||
itemParent = Instantiate(prefabPage, pageParent).transform;
|
||||
pageCountNum++;
|
||||
}
|
||||
|
||||
GameObject obj = Instantiate(prefabItem,itemParent);
|
||||
GameObject obj = Instantiate(prefabItem,pageParent);
|
||||
propsObjHashCode_Dic[obj.GetHashCode()] = product;
|
||||
obj.transform.GetChild(1).GetComponent<TextMeshProUGUI>().text= product.count.ToString();
|
||||
obj.GetComponent<Toggle>().onValueChanged.AddListener((value) =>
|
||||
@@ -74,25 +71,7 @@ public class UIHome_BY_BackPackPanel : SubUIBase
|
||||
|
||||
i++;
|
||||
}
|
||||
btn_Next.onClick.AddListener(() =>
|
||||
{
|
||||
|
||||
if (pageNum > 1)
|
||||
{
|
||||
pageNum--;
|
||||
}
|
||||
text_PageNum.text = pageNum + "/" + pageCountNum;
|
||||
scrollRect.horizontalNormalizedPosition = (float)(pageNum - 1) / (float)(pageCountNum - 1);
|
||||
});
|
||||
btn_Up.onClick.AddListener(() =>
|
||||
{
|
||||
if (pageNum < pageCountNum)
|
||||
{
|
||||
pageNum++;
|
||||
}
|
||||
text_PageNum.text = pageNum + "/" + pageCountNum;
|
||||
scrollRect.horizontalNormalizedPosition = (float)(pageNum - 1) / (float)(pageCountNum - 1);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user