1
This commit is contained in:
@@ -237,16 +237,11 @@ public class UIHome_BY_BackPackPanel : SubUIBase
|
||||
Destroy(pageParent.GetChild(j).gameObject);
|
||||
propsObjHashCode_Dic.Clear();
|
||||
|
||||
bool isfirst = true;
|
||||
Toggle firstToggle = null;
|
||||
Toggle savedToggle = null;
|
||||
|
||||
foreach (BaseProductCount product in propsID_Dic.Values)
|
||||
{
|
||||
// 第一项或与保存的选中id匹配 → 设为选中详情
|
||||
if (isfirst || product.number == savedPropID)
|
||||
{
|
||||
ShowPropDetail(product);
|
||||
isfirst = false;
|
||||
}
|
||||
|
||||
GameObject obj = Instantiate(prefabItem.gameObject, pageParent);
|
||||
var tempItem = obj.GetComponent<BackPackPropItem>();
|
||||
tempItem.Init(new BackPackPropItemData
|
||||
@@ -256,17 +251,21 @@ public class UIHome_BY_BackPackPanel : SubUIBase
|
||||
propEnum = (PropEnum)product.type
|
||||
});
|
||||
|
||||
var toggle = obj.GetComponent<Toggle>();
|
||||
propsObjHashCode_Dic[obj.GetHashCode()] = product;
|
||||
string capturedNum = product.number;
|
||||
if (firstToggle == null) firstToggle = toggle;
|
||||
if (!string.IsNullOrEmpty(savedPropID) && product.number == savedPropID)
|
||||
savedToggle = toggle;
|
||||
|
||||
obj.GetComponent<Toggle>().onValueChanged.AddListener((value) =>
|
||||
{
|
||||
if (value) ShowPropDetail(product);
|
||||
});
|
||||
}
|
||||
|
||||
// 默认选中第一项(isOn 触发 onValueChanged 自动显示详情)
|
||||
if (pageParent.childCount > 0)
|
||||
pageParent.GetChild(0).GetComponent<Toggle>().isOn = true;
|
||||
// 优先选中刷新前的道具;若已用完则选中第一个
|
||||
var target = savedToggle ?? firstToggle;
|
||||
if (target != null) target.isOn = true;
|
||||
}
|
||||
|
||||
private void ShowPropDetail(BaseProductCount product)
|
||||
|
||||
Reference in New Issue
Block a user