1
This commit is contained in:
@@ -38,6 +38,13 @@ public class UIHome_BY_VIPPanel : SubUIBase
|
||||
{
|
||||
base.Awake();
|
||||
vipConfigs = GameManager.Instance.gameConfig.vipLevelConfigs;
|
||||
GameManager.Instance.OnUserDataChanged += OnUserDataChanged;
|
||||
}
|
||||
|
||||
private void OnUserDataChanged()
|
||||
{
|
||||
vipLevel = GameManager.Instance.user.assets.vipLevel;
|
||||
// 打开时 OnShow 会重建所有,这里不需要额外处理
|
||||
}
|
||||
|
||||
protected override void OnShow(object args = null)
|
||||
@@ -47,18 +54,15 @@ public class UIHome_BY_VIPPanel : SubUIBase
|
||||
if (vipConfigs == null || vipConfigs.Count == 0) return;
|
||||
|
||||
var assets = GameManager.Instance.user.assets;
|
||||
var staticInfo = GameManager.Instance.user.@static;
|
||||
vipLevel = assets.vipLevel;
|
||||
|
||||
// 直接清除旧选项 + 构建新选项
|
||||
// 先清除旧选项再重建
|
||||
BuildLevelTabs();
|
||||
|
||||
// 强制选中当前 VIP 等级并刷新数据
|
||||
UpdateVIPPanel(vipLevel);
|
||||
// 通过设置 toggle.isOn 触发 onValueChanged → 自动调用 UpdateVIPPanel
|
||||
for (int i = 0; i < btn_LeaveItemParent.childCount; i++)
|
||||
{
|
||||
int level = vipConfigs[i].level;
|
||||
if (level == vipLevel)
|
||||
if (vipConfigs[i].level == vipLevel)
|
||||
{
|
||||
btn_LeaveItemParent.GetChild(i).GetComponent<Toggle>().isOn = true;
|
||||
break;
|
||||
@@ -68,9 +72,9 @@ public class UIHome_BY_VIPPanel : SubUIBase
|
||||
|
||||
private void BuildLevelTabs()
|
||||
{
|
||||
// 清空旧选项(立即销毁避免残留)
|
||||
// 清空旧选项
|
||||
for (int i = btn_LeaveItemParent.childCount - 1; i >= 0; i--)
|
||||
DestroyImmediate(btn_LeaveItemParent.GetChild(i).gameObject);
|
||||
Destroy(btn_LeaveItemParent.GetChild(i).gameObject);
|
||||
|
||||
foreach (var item in vipConfigs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user