From 287973be2a719141f315e9a54a71971c1f40a696 Mon Sep 17 00:00:00 2001 From: yzx Date: Wed, 5 Jun 2024 10:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=AE=8C=E6=88=90=E8=83=8C?= =?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/ToolsPack/ToolsPackManager.cs | 31 ++++++++++++++----- .../ToolsPackWindowItemBtComponent.cs | 9 ++++-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/SXElectricityInformationAcquisition/Assets/Scripts/ToolsPack/ToolsPackManager.cs b/SXElectricityInformationAcquisition/Assets/Scripts/ToolsPack/ToolsPackManager.cs index e97bc66a..5c730771 100644 --- a/SXElectricityInformationAcquisition/Assets/Scripts/ToolsPack/ToolsPackManager.cs +++ b/SXElectricityInformationAcquisition/Assets/Scripts/ToolsPack/ToolsPackManager.cs @@ -6,6 +6,7 @@ using DefaultNamespace; using MotionFramework; using MotionFramework.Scripts.Runtime.Engine.Engine.Network.WebRequest; using Newtonsoft.Json.Linq; +using ToolsPack; using Unity.VisualScripting; using UnityEngine; @@ -87,9 +88,22 @@ public class ToolsPackManager : ModuleSingleton, IModule /// 删除工具包 /// /// - public void DeleteToolsPack(string toolsName) + public void DeleteToolsPack(string toolsName, int index) { - _toolsPack.Remove(toolsName); + if (_toolsPack[toolsName].Count > 0) + { + for (int i = 0; i < _toolsPack[toolsName].Count; i++) + { + if (i == index) + { + _toolsPack[toolsName].RemoveAt(i); + } + } + } + else + { + _toolsPack.Remove(toolsName); + } } /// @@ -98,8 +112,6 @@ public class ToolsPackManager : ModuleSingleton, IModule /// public Dictionary> GetToolsPack() { - - return _toolsPack; } @@ -107,7 +119,7 @@ public class ToolsPackManager : ModuleSingleton, IModule /// 根据名字查询工具包内容 /// /// - public GameObject GetToolsPack(string toolsName,int index) + public GameObject GetToolsPack(string toolsName, int index) { List game; if (_toolsPack.TryGetValue(toolsName, out game)) @@ -185,7 +197,12 @@ public class ToolsPackManager : ModuleSingleton, IModule _toolsPackWindowItemBts.Clear(); } - public void DeleteToolsPackWindowItemBts(string toolName) + /// + /// 删除背包里的UI按钮 + /// + /// + /// + public void DeleteToolsPackWindowItemBts(string toolName, int index) { List list = MotionEngine.GetModule().GetToolsPackData(toolName); if (list != null) @@ -194,7 +211,7 @@ public class ToolsPackManager : ModuleSingleton, IModule { for (int j = 0; j < list.Count; j++) { - if (_toolsPackWindowItemBts[i].name == list[j]) + if (_toolsPackWindowItemBts[i].name == list[j] && _toolsPackWindowItemBts[i].GetComponent().GetIndex() == index) { GameObject g = _toolsPackWindowItemBts[i]; _toolsPackWindowItemBts.Remove(g); diff --git a/SXElectricityInformationAcquisition/Assets/Scripts/ToolsPack/ToolsPackWindowItemBtComponent.cs b/SXElectricityInformationAcquisition/Assets/Scripts/ToolsPack/ToolsPackWindowItemBtComponent.cs index 797accce..18db4ee6 100644 --- a/SXElectricityInformationAcquisition/Assets/Scripts/ToolsPack/ToolsPackWindowItemBtComponent.cs +++ b/SXElectricityInformationAcquisition/Assets/Scripts/ToolsPack/ToolsPackWindowItemBtComponent.cs @@ -22,8 +22,8 @@ namespace ToolsPack { GameObject toolsGame = MotionEngine.GetModule().GetToolsPack(btName,index); toolsGame.SetActive(true); - MotionEngine.GetModule().DeleteToolsPack(btName); - MotionEngine.GetModule().DeleteToolsPackWindowItemBts(btName); + MotionEngine.GetModule().DeleteToolsPack(btName,index); + MotionEngine.GetModule().DeleteToolsPackWindowItemBts(btName,index); }); } @@ -52,5 +52,10 @@ namespace ToolsPack { btNameText.gameObject.SetActive(false); } + + public int GetIndex() + { + return index; + } } } \ No newline at end of file