Compare commits
2 Commits
86dedea73f
...
9bcec30603
| Author | SHA1 | Date |
|---|---|---|
|
|
9bcec30603 | |
|
|
dcbecd6c46 |
|
|
@ -18,12 +18,11 @@ public enum ToolsPackScene
|
|||
/// <summary>
|
||||
/// 工具包
|
||||
/// </summary>
|
||||
public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||
public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||
{
|
||||
|
||||
private Dictionary<string, GameObject> _toolsPack;
|
||||
private Dictionary<string, List<GameObject>> _toolsPack;
|
||||
private Dictionary<string, Texture2D> _toolsPackWindowBtImage; //工具窗口下的按钮图集
|
||||
private List<GameObject> _toolsPackWindowItemBts;//工具窗口下创建的按钮集合,点击按钮的X用来删除和新增
|
||||
private List<GameObject> _toolsPackWindowItemBts; //工具窗口下创建的按钮集合,点击按钮的X用来删除和新增
|
||||
private GameObject _toolsPackWindow;
|
||||
private GameObject _toolsPackWindowBt;
|
||||
private Transform _canvas;
|
||||
|
|
@ -33,7 +32,7 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
|
||||
public void OnCreate(object createParam)
|
||||
{
|
||||
_toolsPack = new Dictionary<string, GameObject>();
|
||||
_toolsPack = new Dictionary<string, List<GameObject>>();
|
||||
_toolsPackWindowItemBts = new List<GameObject>();
|
||||
//加载工具窗口按钮
|
||||
_toolsPackWindowBt = Resources.Load<GameObject>("Prefabs/Window/ToolsPack/ToolsPackWindowItemBt");
|
||||
|
|
@ -76,7 +75,11 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
{
|
||||
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>
|
||||
/// <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))
|
||||
{
|
||||
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)
|
||||
|
|
@ -160,10 +169,12 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
|
||||
return _canvas;
|
||||
}
|
||||
|
||||
public ToolsPackScene GetToolsPackScene()
|
||||
{
|
||||
return _toolsPackScene;
|
||||
}
|
||||
|
||||
public void SetToolsPackScene(ToolsPackScene toolsPackScene)
|
||||
{
|
||||
_toolsPackScene = toolsPackScene;
|
||||
|
|
@ -173,14 +184,15 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
{
|
||||
_toolsPackWindowItemBts.Add(toolGame);
|
||||
}
|
||||
|
||||
public void ClearToolsPackWindowItemBts()
|
||||
{
|
||||
_toolsPackWindowItemBts.Clear();
|
||||
}
|
||||
|
||||
public void DeleteToolsPackWindowItemBts(string toolName)
|
||||
{
|
||||
|
||||
List<string> list = MotionEngine.GetModule<DataConfigManager>().GetToolsPackData(toolName);
|
||||
List<string> list = MotionEngine.GetModule<DataConfigManager>().GetToolsPackData(toolName);
|
||||
if (list != null)
|
||||
{
|
||||
for (int i = 0; i < _toolsPackWindowItemBts.Count; i++)
|
||||
|
|
@ -208,7 +220,5 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ namespace ToolsPack
|
|||
[SerializeField] private RawImage ico;
|
||||
[SerializeField] private GameObject closeBt;
|
||||
[SerializeField] private string btName;
|
||||
[SerializeField] private int index;
|
||||
[SerializeField] private Text btNameText;
|
||||
|
||||
|
||||
|
|
@ -19,18 +20,18 @@ namespace ToolsPack
|
|||
{
|
||||
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);
|
||||
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPack(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;
|
||||
this.btName = btName;
|
||||
|
||||
this.index = index;
|
||||
ico.texture = MotionEngine.GetModule<ToolsPackManager>().GetToolsPackWindowBtImage(gName);
|
||||
if (MotionEngine.GetModule<ToolsPackManager>().GetToolsPackScene() == ToolsPackScene.工具间)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,11 +32,12 @@ namespace ToolsPack
|
|||
foreach (var v in _toolsNames)
|
||||
{
|
||||
List<string> li = MotionEngine.GetModule<DataConfigManager>().GetToolsPackData(v);
|
||||
|
||||
if (li == null)
|
||||
{
|
||||
ToolsPackWindowItemBtComponent btComponent = Instantiate(bt, content, false).GetComponent<ToolsPackWindowItemBtComponent>();
|
||||
btComponent.name = v;
|
||||
btComponent.Init(v,v);
|
||||
// btComponent.Init(v,v);
|
||||
MotionEngine.GetModule<ToolsPackManager>().AddToolsPackWindowItemBts(btComponent.gameObject);
|
||||
}
|
||||
else
|
||||
|
|
@ -45,7 +46,7 @@ namespace ToolsPack
|
|||
{
|
||||
ToolsPackWindowItemBtComponent btComponent = Instantiate(bt, content, false).GetComponent<ToolsPackWindowItemBtComponent>();
|
||||
btComponent.name = to;
|
||||
btComponent.Init(to,v);
|
||||
// btComponent.Init(to,v);
|
||||
MotionEngine.GetModule<ToolsPackManager>().AddToolsPackWindowItemBts(btComponent.gameObject);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue