76 lines
1.8 KiB
C#
76 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LineGroupManager : MonoBehaviour
|
|
{
|
|
public static LineGroupManager Instance;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
public GameObject panel_object;
|
|
|
|
public InputField line_group_name_inputfield;
|
|
public Button add_line_group_button;
|
|
/// <summary>
|
|
/// 线缆组容器
|
|
/// </summary>
|
|
public GameObject line_group_content;
|
|
|
|
public List<LineGroupItem> child_line_group_items = new List<LineGroupItem>();
|
|
|
|
private void Start()
|
|
{
|
|
add_line_group_button.onClick.AddListener(() =>
|
|
{
|
|
LineQuery.Inst.StartCoroutine(LineQuery.Inst.getJsonCoroutine());
|
|
if (!string.IsNullOrWhiteSpace(line_group_name_inputfield.text))
|
|
{
|
|
AddLineGroup(line_group_name_inputfield.text);
|
|
}
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示面板
|
|
/// </summary>
|
|
public void ShowPanel()
|
|
{
|
|
panel_object.SetActive(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 隐藏面板
|
|
/// </summary>
|
|
public void HidePanel()
|
|
{
|
|
panel_object.SetActive(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加线缆组
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void AddLineGroup(string name)
|
|
{
|
|
//判断是否有重复
|
|
if (child_line_group_items.Find(x => x.info_text.text == name))
|
|
{
|
|
SecondConfirmPanel.DeleteConform(null, "存在重复名称");
|
|
return;
|
|
}
|
|
|
|
var item = LineObjectPool.Instance.GetItemFromPool<LineGroupItem>();
|
|
item.transform.SetParent(line_group_content.transform);
|
|
child_line_group_items.Add(item);
|
|
//传递数据
|
|
item.info_text.text = name;
|
|
|
|
//处理完毕后清空输入框
|
|
line_group_name_inputfield.SetTextWithoutNotify("");
|
|
}
|
|
}
|