diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_InventoryUI.cs b/Assets/PerfectWorld/Scripts/Managers/EC_InventoryUI.cs index f3773eb874..33ca375e57 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_InventoryUI.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_InventoryUI.cs @@ -211,6 +211,8 @@ namespace BrewMonster.Scripts.Managers { if (splitPanelRoot != null) splitPanelRoot.SetActive(show); + if (IsSplitCloseButtonOnModal() && splitCloseButton != null) + splitCloseButton.gameObject.SetActive(show); } /// @@ -1197,6 +1199,50 @@ namespace BrewMonster.Scripts.Managers private void ShowDetailPanel(bool show) { EC_UIUtility.ShowPanel(detailPanelRoot.gameObject, show); + if (!show) + RefreshSplitControlsVisibility(0, null); + } + + /// + /// Split affordance only for main bag stacks (same as ). + /// If splitCloseButton is parented under splitPanelRoot, its visibility follows the modal (not this rule). + /// + private bool IsSplitCloseButtonOnModal() + { + return splitPanelRoot != null && splitCloseButton != null && + splitCloseButton.transform.IsChildOf(splitPanelRoot.transform); + } + + private bool CanShowSplitControls(byte package, EC_IvtrItem item) + { + if (item == null) + return false; + if (package != PKG_INVENTORY) + return false; + int n = item.GetCount(); + if (n < 2 && item.m_iCount >= 2) + n = item.m_iCount; + return n >= 2; + } + + /// + /// splitOpenButton: show only when a splittable main-bag stack is selected (detail panel). + /// splitCloseButton: if it lives on the split modal, show only when modal is open; else same as open (detail-placed cancel). + /// + private void RefreshSplitControlsVisibility(byte package, EC_IvtrItem item) + { + bool canSplit = CanShowSplitControls(package, item); + + if (splitOpenButton != null) + splitOpenButton.gameObject.SetActive(canSplit); + + if (splitCloseButton != null) + { + if (IsSplitCloseButtonOnModal()) + splitCloseButton.gameObject.SetActive(splitPanelRoot != null && splitPanelRoot.activeSelf); + else + splitCloseButton.gameObject.SetActive(canSplit); + } } private Button GetButtonForSlot(byte package, int slot) @@ -1297,6 +1343,8 @@ namespace BrewMonster.Scripts.Managers // Show panel first // 先显示面板 ShowDetailPanel(true); + // After detail root is active so child buttons actually appear (fixes split controls under inactive parents). + RefreshSplitControlsVisibility(package, item); //Refresh the position of the description text. Used for UI logic purpose. descriptionText.tmp.gameObject.GetComponent()?.RefreshLayout();