122 lines
3.4 KiB
C#
122 lines
3.4 KiB
C#
using NOT_Lonely;
|
|
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(() =>
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(line_group_name_inputfield.text))
|
|
{
|
|
//AddLineGroup(line_group_name_inputfield.text);
|
|
LineQuery.Inst.StartCoroutine(LineQuery.Inst.SaveJsonCoroutine(line_group_name_inputfield.text));
|
|
}
|
|
});
|
|
}
|
|
|
|
public void addxianlan()
|
|
{
|
|
|
|
GameObject xianlan = PatternChoose.Inst.xianlan.gameObject;
|
|
GameManager.Inst.FindPortPos();
|
|
|
|
for (int i = 0; i < child_line_group_items.Count; i++)
|
|
{
|
|
LineGroupItem lineGroupItem = child_line_group_items[i].GetComponent<LineGroupItem>();
|
|
lineGroupItem.ClearChilds();
|
|
for (int j = 0; j < xianlan.transform.childCount; j++)
|
|
{
|
|
//if (xianlan.transform.GetChild(j).GetComponent<LineInfor>().cableGroupName == child_line_group_items[i].info_text.text)
|
|
if (xianlan.transform.GetChild(j).name == child_line_group_items[i].info_text.text)
|
|
{
|
|
|
|
//lineGroupItem.AddLineItem(xianlan.transform.GetChild(j).GetComponent<LineInfor>().cableName);
|
|
foreach (var item in xianlan.transform.GetChild(j).GetComponentsInChildren<ACC_Trail>(true))
|
|
{
|
|
lineGroupItem.AddLineItem(item.name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void AddLineGroupInit()
|
|
{
|
|
foreach (var item in LineQuery.Inst.keyValues)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(item.Key))
|
|
{
|
|
AddLineGroup(item.Key);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// ÏÔÊ¾Ãæ°å
|
|
/// </summary>
|
|
public void ShowPanel()
|
|
{
|
|
panel_object.SetActive(true);
|
|
AddLineGroupInit();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Òþ²ØÃæ°å
|
|
/// </summary>
|
|
public void HidePanel()
|
|
{
|
|
panel_object.SetActive(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ìí¼ÓÏßÀÂ×é
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void AddLineGroup(string name,bool success = true)
|
|
{
|
|
if (!success)
|
|
{
|
|
SecondConfirmPanel.DeleteConform(null, "²Ù×÷ʧ°Ü");
|
|
return;
|
|
}
|
|
//ÅжÏÊÇ·ñÓÐÖØ¸´
|
|
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("");
|
|
}
|
|
}
|