using UnityEngine; using UnityEngine.UI; public class LineItem : MonoBehaviour { public LineGroupItem lineGroupItem; public string id; public Text info_text; public Text item_tittle_start_text; public Text item_tittle_end_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(); } // 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(() => { LineGroupManager.Instance.panel_object.SetActive(false); Debug.Log("修改"); //判断起始端口 LocatingCable locatingCable = GetComponent(); PortQuery p = new PortQuery(); if (locatingCable.lines[0].GetComponent().portList.startFlag == 1) { p = locatingCable.lines[0].GetComponent(); GameManager.Inst.nowDevice = locatingCable.lines[0].gameObject; RedactPort.Inst.PortList1_game = locatingCable.lines[0].gameObject; RedactPort.Inst.PortList2 = locatingCable.lines[1].GetComponent().portList; } else { p = locatingCable.lines[1].GetComponent(); GameManager.Inst.nowDevice = locatingCable.lines[1].gameObject; RedactPort.Inst.PortList1_game = locatingCable.lines[1].gameObject; RedactPort.Inst.PortList2 = locatingCable.lines[0].GetComponent().portList; } GameManager.Inst.nowDeviceID = p.portList.id; RedactPort.Inst.PortList1 = p.portList; RedactPort.Inst.OnToggleChanged(RedactPort.Inst.toggle); RedactPort.Inst.AutoShowInfo(RedactPort.Inst.PortList1); PatternChoose.Inst.dk_bj_page.SetActive(true); }); delete_button.onClick.AddListener(() => { //删除确认 SecondConfirmPanel.DeleteConform((delete) => { if (delete) { //LineGroupItem lineGroup = transform.parent.parent.GetComponent(); //LineQuery.Inst.deleteCableName(lineGroupItem.info_text.text, info_text.text, (x) => LineQuery.Inst.deleteCableName(GetComponent(), (x) => { if (!string.IsNullOrEmpty(x)) { LineObjectPool.Instance.PushItemToPool(this); } else { Debug.Log("端口ID为空"); } }); } }); }); } /// /// 清除自身信息以供下次使用 /// public void Clear() { id = string.Empty; info_text.text = string.Empty; lineGroupItem = null; } }