Compare commits

...

2 Commits

Author SHA1 Message Date
yzx 9bcec30603 Merge branch 'SXElectricityInformationAcquisition' of http://gitea.umayle.com/huangjiayu/ShanxiKnowledgeBase into SXElectricityInformationAcquisition
# Conflicts:
#	SXElectricityInformationAcquisition/Assets/Scenes/工具间Scenes/工具间.unity
2024-06-04 20:14:06 +08:00
yzx dcbecd6c46 提交 2024-06-04 20:13:51 +08:00
3 changed files with 38 additions and 26 deletions

View File

@ -18,22 +18,21 @@ public enum ToolsPackScene
/// <summary> /// <summary>
/// 工具包 /// 工具包
/// </summary> /// </summary>
public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
{ {
private Dictionary<string, List<GameObject>> _toolsPack;
private Dictionary<string, GameObject> _toolsPack;
private Dictionary<string, Texture2D> _toolsPackWindowBtImage; //工具窗口下的按钮图集 private Dictionary<string, Texture2D> _toolsPackWindowBtImage; //工具窗口下的按钮图集
private List<GameObject> _toolsPackWindowItemBts;//工具窗口下创建的按钮集合,点击按钮的X用来删除和新增 private List<GameObject> _toolsPackWindowItemBts; //工具窗口下创建的按钮集合,点击按钮的X用来删除和新增
private GameObject _toolsPackWindow; private GameObject _toolsPackWindow;
private GameObject _toolsPackWindowBt; private GameObject _toolsPackWindowBt;
private Transform _canvas; private Transform _canvas;
private GameObject _toolsPackWindowTemp; private GameObject _toolsPackWindowTemp;
private ToolsPackScene _toolsPackScene; private ToolsPackScene _toolsPackScene;
public void OnCreate(object createParam) public void OnCreate(object createParam)
{ {
_toolsPack = new Dictionary<string, GameObject>(); _toolsPack = new Dictionary<string, List<GameObject>>();
_toolsPackWindowItemBts = new List<GameObject>(); _toolsPackWindowItemBts = new List<GameObject>();
//加载工具窗口按钮 //加载工具窗口按钮
_toolsPackWindowBt = Resources.Load<GameObject>("Prefabs/Window/ToolsPack/ToolsPackWindowItemBt"); _toolsPackWindowBt = Resources.Load<GameObject>("Prefabs/Window/ToolsPack/ToolsPackWindowItemBt");
@ -76,7 +75,11 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
{ {
if (!_toolsPack.ContainsKey(toolsName)) if (!_toolsPack.ContainsKey(toolsName))
{ {
_toolsPack.Add(toolsName, toolsGame); _toolsPack.Add(toolsName, new List<GameObject>() { toolsGame });
}
else
{
_toolsPack[toolsName].Add(toolsGame);
} }
} }
@ -109,15 +112,21 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
/// 根据名字查询工具包内容 /// 根据名字查询工具包内容
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public (string, GameObject) GetToolsPack(string toolsName) public GameObject GetToolsPack(string toolsName,int index)
{ {
GameObject game; List<GameObject> game;
if (_toolsPack.TryGetValue(toolsName, out game)) if (_toolsPack.TryGetValue(toolsName, out game))
{ {
return (toolsName, game); for (int i = 0; i < game.Count; i++)
{
if (i == index)
{
return (game[i]);
}
}
} }
return (toolsName, null); return null;
} }
public Texture2D GetToolsPackWindowBtImage(string gName) public Texture2D GetToolsPackWindowBtImage(string gName)
@ -135,17 +144,17 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
{ {
return _toolsPackWindow; return _toolsPackWindow;
} }
public GameObject GetToolsPackWindowBt() public GameObject GetToolsPackWindowBt()
{ {
return _toolsPackWindowBt; return _toolsPackWindowBt;
} }
public GameObject GetToolsPackWindowTemp() public GameObject GetToolsPackWindowTemp()
{ {
return _toolsPackWindowTemp; return _toolsPackWindowTemp;
} }
public void SetToolsPackWindowTemp(GameObject win) public void SetToolsPackWindowTemp(GameObject win)
{ {
_toolsPackWindowTemp = win; _toolsPackWindowTemp = win;
@ -160,10 +169,12 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
return _canvas; return _canvas;
} }
public ToolsPackScene GetToolsPackScene() public ToolsPackScene GetToolsPackScene()
{ {
return _toolsPackScene; return _toolsPackScene;
} }
public void SetToolsPackScene(ToolsPackScene toolsPackScene) public void SetToolsPackScene(ToolsPackScene toolsPackScene)
{ {
_toolsPackScene = toolsPackScene; _toolsPackScene = toolsPackScene;
@ -173,14 +184,15 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
{ {
_toolsPackWindowItemBts.Add(toolGame); _toolsPackWindowItemBts.Add(toolGame);
} }
public void ClearToolsPackWindowItemBts() public void ClearToolsPackWindowItemBts()
{ {
_toolsPackWindowItemBts.Clear(); _toolsPackWindowItemBts.Clear();
} }
public void DeleteToolsPackWindowItemBts(string toolName) public void DeleteToolsPackWindowItemBts(string toolName)
{ {
List<string> list = MotionEngine.GetModule<DataConfigManager>().GetToolsPackData(toolName);
List<string> list = MotionEngine.GetModule<DataConfigManager>().GetToolsPackData(toolName);
if (list != null) if (list != null)
{ {
for (int i = 0; i < _toolsPackWindowItemBts.Count; i++) for (int i = 0; i < _toolsPackWindowItemBts.Count; i++)
@ -208,7 +220,5 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
} }
} }
} }
} }
} }

View File

@ -12,6 +12,7 @@ namespace ToolsPack
[SerializeField] private RawImage ico; [SerializeField] private RawImage ico;
[SerializeField] private GameObject closeBt; [SerializeField] private GameObject closeBt;
[SerializeField] private string btName; [SerializeField] private string btName;
[SerializeField] private int index;
[SerializeField] private Text btNameText; [SerializeField] private Text btNameText;
@ -19,18 +20,18 @@ namespace ToolsPack
{ {
closeBt.GetComponent<Button>().onClick.AddListener(delegate closeBt.GetComponent<Button>().onClick.AddListener(delegate
{ {
(string str, GameObject toolsGame) = MotionEngine.GetModule<ToolsPackManager>().GetToolsPack(btName); GameObject toolsGame = MotionEngine.GetModule<ToolsPackManager>().GetToolsPack(btName,index);
toolsGame.SetActive(true); toolsGame.SetActive(true);
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPack(btName); MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPack(btName);
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPackWindowItemBts(btName); MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPackWindowItemBts(btName);
}); });
} }
public void Init(string gName, string btName) public void Init(string gName, string btName,int index)
{ {
btNameText.text = gName; btNameText.text = gName;
this.btName = btName; this.btName = btName;
this.index = index;
ico.texture = MotionEngine.GetModule<ToolsPackManager>().GetToolsPackWindowBtImage(gName); ico.texture = MotionEngine.GetModule<ToolsPackManager>().GetToolsPackWindowBtImage(gName);
if (MotionEngine.GetModule<ToolsPackManager>().GetToolsPackScene() == ToolsPackScene.) if (MotionEngine.GetModule<ToolsPackManager>().GetToolsPackScene() == ToolsPackScene.)
{ {

View File

@ -32,11 +32,12 @@ namespace ToolsPack
foreach (var v in _toolsNames) foreach (var v in _toolsNames)
{ {
List<string> li = MotionEngine.GetModule<DataConfigManager>().GetToolsPackData(v); List<string> li = MotionEngine.GetModule<DataConfigManager>().GetToolsPackData(v);
if (li == null) if (li == null)
{ {
ToolsPackWindowItemBtComponent btComponent = Instantiate(bt, content, false).GetComponent<ToolsPackWindowItemBtComponent>(); ToolsPackWindowItemBtComponent btComponent = Instantiate(bt, content, false).GetComponent<ToolsPackWindowItemBtComponent>();
btComponent.name = v; btComponent.name = v;
btComponent.Init(v,v); // btComponent.Init(v,v);
MotionEngine.GetModule<ToolsPackManager>().AddToolsPackWindowItemBts(btComponent.gameObject); MotionEngine.GetModule<ToolsPackManager>().AddToolsPackWindowItemBts(btComponent.gameObject);
} }
else else
@ -45,7 +46,7 @@ namespace ToolsPack
{ {
ToolsPackWindowItemBtComponent btComponent = Instantiate(bt, content, false).GetComponent<ToolsPackWindowItemBtComponent>(); ToolsPackWindowItemBtComponent btComponent = Instantiate(bt, content, false).GetComponent<ToolsPackWindowItemBtComponent>();
btComponent.name = to; btComponent.name = to;
btComponent.Init(to,v); // btComponent.Init(to,v);
MotionEngine.GetModule<ToolsPackManager>().AddToolsPackWindowItemBts(btComponent.gameObject); MotionEngine.GetModule<ToolsPackManager>().AddToolsPackWindowItemBts(btComponent.gameObject);
} }
} }