using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LineGroupItem : MonoBehaviour
{
public string id;
///
/// 标题
///
public Text info_text;
///
/// 删除
///
public Button delete_button;
///
/// 展开
///
public Button expand_button;
///
/// 线缆容器
///
public GameObject line_item_content;
///
/// 线缆组中的线
///
public List child_line_items = new List();
bool do_init = false;
// Start is called before the first frame update
void Start()
{
if (!do_init)
Init();
}
public void Init()
{
do_init = true;
expand_button.onClick.AddListener(() =>
{
line_item_content.SetActive(!line_item_content.activeSelf);
});
delete_button.onClick.AddListener(() =>
{
//删除确认
SecondConfirmPanel.DeleteConform((delete) =>
{
if (delete)
{
LineObjectPool.Instance.PushItemToPool(this);
}
});
});
}
///
/// 添加线缆
///
[ContextMenu("添加")]
public void AddLineItem()
{
var item = LineObjectPool.Instance.GetItemFromPool();
item.transform.SetParent(line_item_content.transform);
child_line_items.Add(item);
//传递数据
item.info_text.text = "线缆数据";
}
///
/// 回收至对象池
///
public void Clear()
{
id = string.Empty;
info_text.text = string.Empty;
for (int i = 0; i < child_line_items.Count; i++)
{
LineObjectPool.Instance.PushItemToPool(child_line_items[i]);
}
}
}