using UnityEngine; using UnityEngine.UI; using static PortQuery; 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; RedactPort.Inst.PortList2_game = locatingCable.lines[1].gameObject; } 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; RedactPort.Inst.PortList2_game = locatingCable.lines[0].gameObject; } GameManager.Inst.nowDeviceID = p.portList.id; RedactPort.Inst.PortList1 = p.portList; RedactPort.Inst.deviceName_dic.Add(RedactPort.Inst.PortList1.deviceName, RedactPort.Inst.PortList1.id); RedactPort.Inst.conDevice_dic.Add(RedactPort.Inst.PortList2.deviceName, RedactPort.Inst.PortList2.id); RedactPort.Inst.OnToggleChanged(RedactPort.Inst.toggle); var _PortList2 = RedactPort.Inst.PortList2;// 记录P2数据 RedactPort.Inst.PortList2 = null;// 为了让P2自动获取,先置空 RedactPort.Inst.AutoShowInfo(p, true); PatternChoose.Inst.dk_bj_page.SetActive(true); RedactPort.Inst.PortList2 = _PortList2; GameManager.Inst.portOpenFlashing(locatingCable.lines[0].gameObject, locatingCable.lines[1].gameObject); }); 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; } }