81 lines
2.1 KiB
C#
81 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LineItem : MonoBehaviour
|
|
{
|
|
public LineGroupItem lineGroupItem;
|
|
public string id;
|
|
public Text info_text;
|
|
public Button delete_button;
|
|
public Button set_button;
|
|
|
|
bool do_init = false;
|
|
|
|
|
|
public LineItem(string _id, Text _info_text, Button _delete_button, Button _set_button, bool isgo = false)
|
|
{
|
|
if (isgo)
|
|
{
|
|
id = _id;
|
|
info_text = _info_text;
|
|
delete_button = _delete_button;
|
|
set_button = _set_button;
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
var g = GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsFindLineGroupItem);
|
|
if (g != null && !lineGroupItem)
|
|
lineGroupItem = g.GetComponent<LineGroupItem>();
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
if (!do_init)
|
|
Init();
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
do_init = true;
|
|
if (set_button)
|
|
set_button.onClick.AddListener(() =>
|
|
{
|
|
Debug.Log("修改");
|
|
});
|
|
delete_button.onClick.AddListener(() =>
|
|
{
|
|
//删除确认
|
|
SecondConfirmPanel.DeleteConform((delete) =>
|
|
{
|
|
if (delete)
|
|
{
|
|
//LineGroupItem lineGroup = transform.parent.parent.GetComponent<LineGroupItem>();
|
|
//LineQuery.Inst.deleteCableName(lineGroup.info_text.text, info_text.text, (x) =>
|
|
LineQuery.Inst.deleteCableName(lineGroupItem.info_text.text, info_text.text, (x) =>
|
|
{
|
|
if (!string.IsNullOrEmpty(x))
|
|
{
|
|
LineObjectPool.Instance.PushItemToPool(this);
|
|
}
|
|
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清除自身信息以供下次使用
|
|
/// </summary>
|
|
public void Clear()
|
|
{
|
|
id = string.Empty;
|
|
info_text.text = string.Empty;
|
|
lineGroupItem = null;
|
|
}
|
|
}
|