GQ_Communicate/GQ_URP/GQ/Assets/script/画线/CreateLine.cs

765 lines
27 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 创建线条
/// </summary>
public class CreateLine : CabinetUIBase
{
/// <summary>
/// 存放线缆父物体
/// </summary>
public Transform xianLan;
//public Transform A5;
//public Transform B5;
//public Transform A6;
//public Transform B6;
//public Transform A7;
//public Transform B7;
//public Transform A7_1;
//public Transform B7_1;
//public Transform A7_2;
//public Transform B7_2;
public List<Transform> list7 = new List<Transform>();
/// <summary>
/// 端口边距
/// </summary>
[Header("端口边距")] public float edge_Distance;
[Header("不同高度集"), SerializeField] List<Transform> _vectors_tall = new List<Transform>();
/// <summary>
/// 不同高度集
/// </summary>
[HideInInspector] public List<Vector3> vectors_tall = new List<Vector3>();
public float lineWidth = 0.1f; // 线的粗细
[HideInInspector] public Color lineColor = Color.white; // 线的颜色
private LineRenderer lineRenderer; // LineRenderer 组件
/// <summary>
/// 当前创建的空物体
/// </summary>
private GameObject go;
private void Awake()
{
for (int i = 0; i < _vectors_tall.Count; i++)
vectors_tall.Add(_vectors_tall[i].position);
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
/// <summary>
/// 生成LineGUID
/// </summary>
public static class UniqueGuidGenerator
{
private static HashSet<string> generatedGuids = new HashSet<string>();
public static string GenerateUniqueGuid()
{
string guidString;
do
{
guidString = Guid.NewGuid().ToString("N");
} while (!generatedGuids.Add(guidString));
return guidString;
}
}
public void init(GameObject go, Color color)
{
lineRenderer = go.GetComponent<LineRenderer>();
if (!lineRenderer) lineRenderer = go.AddComponent<LineRenderer>();
//lineRenderer.material = new Material(Shader.Find("Sprites/Default"));
lineRenderer.material = GameObject.Instantiate<Material>(Resources.Load<Material>("emission"));
//lineRenderer.material.color = color;
lineRenderer.material.color = lineColor;
lineRenderer.startWidth = lineWidth;
lineRenderer.endWidth = lineWidth;
lineRenderer.startColor = lineColor;
lineRenderer.endColor = lineColor;
lineRenderer.numCornerVertices = 90; // 设置角处的顶点数
lineRenderer.numCapVertices = 90; // 设置端点处的顶点数
lineRenderer.useWorldSpace = false; // 将坐标设置为局部坐标
//lineRenderer.positionCount = (numSegments + 1) * 2;
//UpdateCylinder();
}
//public float radius = 1f; // 圆柱体半径
//public float height = 1f; // 圆柱体高度
//public int numSegments = 32; // 圆柱体分段数
void UpdateCylinder()
{
//float segmentAngle = 2 * Mathf.PI / numSegments;
//float currentAngle = 0f;
//for (int i = 0; i <= numSegments; i++)
//{
// float x = Mathf.Cos(currentAngle);
// float z = Mathf.Sin(currentAngle);
// Vector3 topPoint = new Vector3(x * radius, height / 2f, z * radius);
// Vector3 bottomPoint = new Vector3(x * radius, -height / 2f, z * radius);
// lineRenderer.SetPosition(i * 2, topPoint);
// lineRenderer.SetPosition(i * 2 + 1, bottomPoint);
// currentAngle += segmentAngle;
//}
}
/// <summary>
/// 同行(分同层、不同层两种)
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="hierarchy">区</param>
public void Creat5(Transform A, Transform B, int hierarchy = 0)//端口是否在模型16上
{
var a = GameManager.Inst.FindParent(A.gameObject, GameManager.Inst.IsDesiredParent);
var b = GameManager.Inst.FindParent(B.gameObject, GameManager.Inst.IsDesiredParent);
var _A16 = GameManager.Inst.FindParent(A.gameObject, GameManager.Inst.IsFindRacks_go).GetComponent<DeviceQuery>().deviceList.modelNum;
var _B16 = GameManager.Inst.FindParent(B.gameObject, GameManager.Inst.IsFindRacks_go).GetComponent<DeviceQuery>().deviceList.modelNum;
bool A16 = _A16 != "16" && _A16 != "37" && _A16 != "41";
bool B16 = _B16 != "16" && _B16 != "37" && _B16 != "41";
//都不在
if (A16 && B16)
{
GameObject xian = null;
var p = A.GetComponent<PortQuery>().portList;
var v = Array.Find(xianLan.GetComponentsInChildren<LineInfor>(), (item) =>
{
return (item.cableGroupName == p.cableGroupName);
});
//CreateNewCablesTrail();
//GameObject prefab_xianlan = prefab_xianlan.gameObject;
if (v == null)
{
go = new GameObject("EmptyObject");
go.name = p.cableGroupName;
go.transform.SetParent(xianLan);
xian = new GameObject(p.cableName);
xian.transform.SetParent(go.transform);
go.SetActive(false);
}
else
{
xian = new GameObject(p.cableName);
go = v.gameObject;
xian.transform.SetParent(go.transform);
//prefab_xianlan.transform.SetParent(v.transform);
//prefab_xianlan.name = p.cableName;
go.SetActive(false);
//setBasicInfo(A, B, prefab_xianlan.gameObject, p);
}
Color newColor = lineColor;
//setColorline(p, prefab_xianlan.gameObject);
try
{
HexToColor(PatternChoose.Inst.xianlan.lineCode_dic[p.portType], (x) =>
{
init(xian, x);
newColor = x;
});
}
catch (Exception e)
{
Debug.Log("匹配线缆颜色错误 " + e.Message + "\n" + e.StackTrace);
init(xian, lineColor);
}
List<Vector3> vector3s = new List<Vector3>();
Vector3 v1 = A.position;
Vector3 v2 = A.position + new Vector3(edge_Distance, 0, 0);
//同层 V3=V4 不同层 V3!=V4
Vector3 v3 = v2 + new Vector3(0, 0, B.position.z - v2.z);
Vector3 v4 = v3 + new Vector3(0, B.position.y - v3.y, 0);
Vector3 v5 = B.position;
vector3s.Add(v1);
if (vector3s[vector3s.Count - 1] != v2) vector3s.Add(v2);
if (vector3s[vector3s.Count - 1] != v3) vector3s.Add(v3);
if (vector3s[vector3s.Count - 1] != v4) vector3s.Add(v4);
if (vector3s[vector3s.Count - 1] != v5) vector3s.Add(v5);
lineRenderer.positionCount = vector3s.Count;
lineRenderer.SetPositions(vector3s.ToArray());
setBasicInfo(A, B, xian, p, newColor);
//setPoss(prefab_xianlan, vector3s);
}
//A在
else if (!A16 && B16)
{
Creat6(A, B, hierarchy);
}
//B在
else if (A16 && !B16)
{
Creat6(B, A, hierarchy);
}
//都在
else if (!A16 && !B16)
{
GameObject xian = null;
var p = A.GetComponent<PortQuery>().portList;
var v = Array.Find(xianLan.GetComponentsInChildren<LineInfor>(), (item) =>
{
return (item.cableGroupName == p.cableGroupName);
});
//CreateNewCablesTrail();
//GameObject prefab_xianlan = prefab_xianlan.gameObject;
if (v == null)
{
go = new GameObject("EmptyObject");
go.name = p.cableGroupName;
go.transform.SetParent(xianLan);
xian = new GameObject(p.cableName);
xian.transform.SetParent(go.transform);
go.SetActive(false);
}
else
{
xian = new GameObject(p.cableName);
go = v.gameObject;
xian.transform.SetParent(go.transform);
//prefab_xianlan.transform.SetParent(v.transform);
//prefab_xianlan.name = p.cableName;
go.SetActive(false);
//setBasicInfo(A, B, prefab_xianlan.gameObject, p);
}
Color newColor = lineColor;
//setColorline(p, prefab_xianlan.gameObject);
try
{
HexToColor(PatternChoose.Inst.xianlan.lineCode_dic[p.portType], (x) =>
{
init(xian, x);
newColor = x;
});
}
catch (Exception e)
{
Debug.Log("匹配线缆颜色错误 " + e.Message + "\n" + e.StackTrace);
init(xian, lineColor);
}
List<Vector3> vector3s = new List<Vector3>();
Vector3 v1 = A.position + new Vector3(-0.06f, 0, 0); ;
Vector3 v2 = A.position + new Vector3(edge_Distance * 2, 0, 0) * -1;
//同层 V3=V4 不同层 V3!=V4
Vector3 v3 = v2 + new Vector3(0, 0, B.position.z - v2.z);
Vector3 v4 = v3 + new Vector3(0, B.position.y - v3.y, 0);
Vector3 v5 = B.position + new Vector3(-0.06f, 0, 0); ;
vector3s.Add(v1);
if (vector3s[vector3s.Count - 1] != v2) vector3s.Add(v2);
if (vector3s[vector3s.Count - 1] != v3) vector3s.Add(v3);
if (vector3s[vector3s.Count - 1] != v4) vector3s.Add(v4);
if (vector3s[vector3s.Count - 1] != v5) vector3s.Add(v5);
lineRenderer.positionCount = vector3s.Count;
lineRenderer.SetPositions(vector3s.ToArray());
setBasicInfo(A, B, xian, p, newColor);
//setPoss(prefab_xianlan, vector3s);
}
}
/// <summary>
/// 设置线缆点
/// </summary>
/// <param name="_prefab"></param>
/// <param name="vector3s"></param>
//public void setPoss(ACC_Trail _prefab, List<Vector3> vector3s)
//{
//_prefab.transform.parent.gameObject.SetActive(true);
//_prefab.controlPoints.Clear();
////var acc = _prefab.GetComponent<ACC_Trail>();
//for (int i = 0; i < vector3s.Count; i++)
//{
// poss[i].position = vector3s[i];
// _prefab.controlPoints.Add(poss[i]);
//}
//_prefab.SetControlPoints();
//_prefab.UpdateSequencesPositions();
//}
// 设置基本信息
public void setBasicInfo(Transform A, Transform B, GameObject xian, PortQuery.PortList p, Color x)
{
//prefab_xianlan.lengthSegments = 5;
//prefab_xianlan.lengthDependentHeight = 0;
//prefab_xianlan.verticalCurvature = 0;
//prefab_xianlan.thickness = new Vector2(0.05f, 0.05f);
var lineInfor = xian.AddComponent<LineInfor>();
lineInfor.newColor = x;
lineInfor.lines.Add(A);
lineInfor.lines.Add(B);
lineInfor.cableGroupName = p.cableGroupName;
lineInfor.cableName = p.cableName;
lineInfor.portType = p.portType;
LineRendererInteraction interaction = xian.AddComponent<LineRendererInteraction>();
interaction.lineInfor = lineInfor;
interaction.lineRenderer = xian.GetComponent<LineRenderer>();
PortQuery p_a = A.GetComponent<PortQuery>();
PortQuery p_b = B.GetComponent<PortQuery>();
GameObject cab_a = GameManager.Inst.FindParent(A.gameObject, GameManager.Inst.IsDesiredParent);
GameObject cab_b = GameManager.Inst.FindParent(B.gameObject, GameManager.Inst.IsDesiredParent);
interaction.popupUI = PatternChoose.Inst.xianlan_popup;
interaction.cableUI = interaction.popupUI.GetComponent<CableUI>();
interaction.port_A = p_a.portList.port;
interaction.port_A_cabinet = cab_a != null ? cab_a.name : null;
interaction.port_A_deviceName = p_a.portList.deviceName;
interaction.port_B = p_b.portList.port;
interaction.port_B_cabinet = cab_b != null ? cab_b.name : null;
interaction.port_B_deviceName = p_b.portList.deviceName;
CreateCableBox(interaction, lineInfor);
}
public void CreateCableBox(LineRendererInteraction interaction, LineInfor lineInfor)
{
lineRenderer = interaction.lineRenderer;
//// 计算折线的边界框
//Bounds bounds = new Bounds(lineRenderer.GetPosition(0), Vector3.zero);
//for (int i = 1; i < lineRenderer.positionCount; i++)
//{
// bounds.Encapsulate(lineRenderer.GetPosition(i));
//}
Bounds bounds = new Bounds(lineRenderer.GetPosition(0), Vector3.zero);
bounds.Encapsulate(lineRenderer.GetPosition(1));
Bounds bounds2 = new Bounds(lineRenderer.GetPosition(lineRenderer.positionCount - 1), Vector3.zero);
bounds2.Encapsulate(lineRenderer.GetPosition(lineRenderer.positionCount - 2));
// 添加BoxCollider组件并设置大小和位置
BoxCollider boxCollider = lineRenderer.gameObject.AddComponent<BoxCollider>();
boxCollider.center = bounds.center;
//boxCollider.size = bounds.size;
boxCollider.size = new Vector3(0.5F, lineInfor.lineWidth_min, lineInfor.lineWidth_min);
BoxCollider boxCollider2 = lineRenderer.gameObject.AddComponent<BoxCollider>();
boxCollider2.center = bounds2.center;
//boxCollider2.size = bounds2.size;
boxCollider2.size = new Vector3(0.5F, lineInfor.lineWidth_min, lineInfor.lineWidth_min);
}
// 生成线缆预制体
public void CreateNewCablesTrail()
{
//prefab_xianlan = new GameObject("Cable Trail", typeof(ACC_Trail)).GetComponent<ACC_Trail>();
//prefab_xianlan.CreateFirstCableSegment(prefab_xianlan.transform);
//prefab_xianlan.UpdateAllSequences();
}
/// <summary>
/// 匹配线缆颜色
/// </summary>
public void setColorline(PortQuery.PortList p, GameObject _prefab)
{
try
{
HexToColor(PatternChoose.Inst.xianlan.lineCode_dic[p.portType], (x) =>
{
//init(x);
_prefab.GetComponent<LineInfor>().newColor = x;
_prefab.GetComponent<LineInfor>().setcolor();
});
//HexToColor(PatternChoose.Inst.xianlan.lineCode_dic[p.portType], (x) =>
//{
// lineRenderer.endColor = x;
//});
}
catch (Exception e)
{
_prefab.GetComponent<LineInfor>().setcolor();
Debug.Log("匹配线缆颜色错误 " + e.Message + "\n" + e.StackTrace);
//init(lineColor);
}
}
private void HexToColor(string hex, Action<Color> callback)
{
if (ColorUtility.TryParseHtmlString(hex, out Color color))
{
callback.Invoke(color);
}
else
{
Debug.LogError("无法识别色值: " + hex);
}
}
/// <summary>
/// A为模型16B不是
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="hierarchy">高度层级</param>
public void Creat6(Transform A, Transform B, int hierarchy = 0)
{
#region old
////init(Color.white);
//List<Vector3> vector3s = new List<Vector3>();
//Vector3 v1 = A.position;
//Vector3 v2 = A.position + new Vector3(edge_Distance, 0, 0);
//Vector3 v3 = v2 + new Vector3(0, vectors_tall[hierarchy].y - v2.y, 0);
//Vector3 v4 = v3 + new Vector3(B.position.x - v3.x + edge_Distance, 0, 0);
//Vector3 v5 = v4 + new Vector3(0, B.position.y - v4.y, 0);
//Vector3 v6 = B.position;
//vector3s.Add(v1);
//vector3s.Add(v2);
//vector3s.Add(v3);
//vector3s.Add(v4);
//vector3s.Add(v5);
//vector3s.Add(v6);
////lineRenderer.positionCount = 6;
////lineRenderer.SetPositions(vector3s.ToArray());
#endregion
GameObject xian = null;
var p = A.GetComponent<PortQuery>().portList;
//var v = Array.Find(xianLan.GetComponentsInChildren<LineInfor>(), (item) =>
var v = Array.Find(xianLan.GetComponentsInChildren<Transform>(), (item) =>
{
//return (item.cableGroupName == p.cableGroupName);
return (item.name == p.cableGroupName);
});
if (v == null)
{
go = new GameObject("EmptyObject");
go.name = p.cableGroupName;
go.transform.SetParent(xianLan);
xian = new GameObject(p.cableName);
xian.transform.SetParent(go.transform);
go.SetActive(false);
}
else
{
xian = new GameObject(p.cableName);
go = v.gameObject;
xian.transform.SetParent(go.transform);
go.SetActive(false);
}
Color newColor = lineColor;
try
{
HexToColor(PatternChoose.Inst.xianlan.lineCode_dic[p.portType], (x) =>
{
init(xian, x);
newColor = x;
});
}
catch (Exception e)
{
Debug.Log("匹配线缆颜色错误 " + e.Message + "\n" + e.StackTrace);
init(xian, lineColor);
}
List<Vector3> vector3s = new List<Vector3>();
Vector3 v1 = A.position + new Vector3(-0.06f, 0, 0);
Vector3 v2 = v1 + new Vector3(edge_Distance * 2, 0, 0) * -1;
Vector3 v3 = v2 + new Vector3(0, vectors_tall[hierarchy].y - v2.y, 0);
Vector3 v4 = v3 + new Vector3(0, 0, B.position.z - v3.z);
Vector3 v5 = v4 + new Vector3(B.position.x - v3.x + edge_Distance, 0, 0);
Vector3 v6 = v5 + new Vector3(0, B.position.y - v5.y, 0);
Vector3 v7 = B.position;
vector3s.Add(v1);
if (vector3s[vector3s.Count - 1] != v2) vector3s.Add(v2);
if (vector3s[vector3s.Count - 1] != v3) vector3s.Add(v3);
if (vector3s[vector3s.Count - 1] != v4) vector3s.Add(v4);
if (vector3s[vector3s.Count - 1] != v5) vector3s.Add(v5);
if (vector3s[vector3s.Count - 1] != v6) vector3s.Add(v6);
if (vector3s[vector3s.Count - 1] != v7) vector3s.Add(v7);
lineRenderer.positionCount = vector3s.Count;
lineRenderer.SetPositions(vector3s.ToArray());
setBasicInfo(A, B, xian, p, newColor);
}
/// <summary>
/// 不同行(分同列、不同列两种)
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="hierarchy">区</param>
public void Creat7(Transform A, Transform B, int hierarchy)//端口是否在模型16上
{
var _A16 = GameManager.Inst.FindParent(A.gameObject, GameManager.Inst.IsFindRacks_go).GetComponent<DeviceQuery>().deviceList.modelNum;
var _B16 = GameManager.Inst.FindParent(B.gameObject, GameManager.Inst.IsFindRacks_go).GetComponent<DeviceQuery>().deviceList.modelNum;
bool A16 = _A16 != "16" && _A16 != "37" && _A16 != "41";
bool B16 = _B16 != "16" && _B16 != "37" && _B16 != "41";
//都不在
if (A16 && B16)
{
GameObject xian = null;
var p = A.GetComponent<PortQuery>().portList;
//var v = Array.Find(xianLan.GetComponentsInChildren<LineInfor>(), (item) =>
var v = Array.Find(xianLan.GetComponentsInChildren<Transform>(), (item) =>
{
//return (item.cableGroupName == p.cableGroupName);
return (item.name == p.cableGroupName);
});
if (v == null)
{
go = new GameObject("EmptyObject");
go.name = p.cableGroupName;
go.transform.SetParent(xianLan);
xian = new GameObject(p.cableName);
xian.transform.SetParent(go.transform);
go.SetActive(false);
}
else
{
xian = new GameObject(p.cableName);
go = v.gameObject;
xian.transform.SetParent(go.transform);
go.SetActive(false);
}
Color newColor = lineColor;
try
{
HexToColor(PatternChoose.Inst.xianlan.lineCode_dic[p.portType], (x) =>
{
init(xian, x);
newColor = x;
});
}
catch (Exception e)
{
Debug.Log("匹配线缆颜色错误 " + e.Message + "\n" + e.StackTrace);
init(xian, lineColor);
}
//setColorline(p, prefab_xianlan.gameObject);
List<Vector3> vector3s = new List<Vector3>();
Vector3 v1 = A.position;
Vector3 v2 = A.position + new Vector3(edge_Distance, 0, 0);
Vector3 v3 = v2 + new Vector3(0, vectors_tall[hierarchy].y - v2.y, 0);
Vector3 v4 = v3 + new Vector3(B.position.x - v3.x + edge_Distance, 0, 0);
Vector3 v5 = v4 + new Vector3(0, 0, B.position.z - v4.z);
Vector3 v6 = v5 + new Vector3(0, B.position.y - v5.y, 0);
Vector3 v7 = B.position;
vector3s.Add(v1);
if (vector3s[vector3s.Count - 1] != v2) vector3s.Add(v2);
if (vector3s[vector3s.Count - 1] != v3) vector3s.Add(v3);
if (vector3s[vector3s.Count - 1] != v4) vector3s.Add(v4);
if (vector3s[vector3s.Count - 1] != v5) vector3s.Add(v5);
if (vector3s[vector3s.Count - 1] != v6) vector3s.Add(v6);
if (vector3s[vector3s.Count - 1] != v7) vector3s.Add(v7);
lineRenderer.positionCount = vector3s.Count;
lineRenderer.SetPositions(vector3s.ToArray());
setBasicInfo(A, B, xian, p, newColor);
}
//A在
else if (!A16 && B16)
{
Creat6(A, B, hierarchy);
}
//B在
else if (A16 && !B16)
{
Creat6(B, A, hierarchy);
}
//都在
else if (!A16 && !B16)
{
GameObject xian = null;
var p = A.GetComponent<PortQuery>().portList;
//var v = Array.Find(xianLan.GetComponentsInChildren<LineInfor>(), (item) =>
var v = Array.Find(xianLan.GetComponentsInChildren<Transform>(), (item) =>
{
//return (item.cableGroupName == p.cableGroupName);
return (item.name == p.cableGroupName);
});
if (v == null)
{
go = new GameObject("EmptyObject");
go.name = p.cableGroupName;
go.transform.SetParent(xianLan);
xian = new GameObject(p.cableName);
xian.transform.SetParent(go.transform);
go.SetActive(false);
}
else
{
xian = new GameObject(p.cableName);
go = v.gameObject;
xian.transform.SetParent(go.transform);
go.SetActive(false);
}
Color newColor = lineColor;
try
{
HexToColor(PatternChoose.Inst.xianlan.lineCode_dic[p.portType], (x) =>
{
init(xian, x);
newColor = x;
});
}
catch (Exception e)
{
Debug.Log("匹配线缆颜色错误 " + e.Message + "\n" + e.StackTrace);
init(xian, lineColor);
}
List<Vector3> vector3s = new List<Vector3>();
Vector3 v1 = A.position + new Vector3(-0.06f, 0, 0);
Vector3 v2 = v1 + new Vector3(edge_Distance * 2, 0, 0) * -1;
Vector3 v3 = v2 + new Vector3(0, vectors_tall[hierarchy].y - v2.y, 0);
Vector3 v4 = v3 + new Vector3(0, 0, B.position.z - v3.z);
Vector3 v5 = v4 + new Vector3(B.position.x - v3.x, 0, 0) + new Vector3(edge_Distance * 2, 0, 0) * -1;
Vector3 v6 = v5 + new Vector3(0, B.position.y - v5.y, 0);
Vector3 v7 = B.position + new Vector3(-0.06f, 0, 0); ;
vector3s.Add(v1);
if (vector3s[vector3s.Count - 1] != v2) vector3s.Add(v2);
if (vector3s[vector3s.Count - 1] != v3) vector3s.Add(v3);
if (vector3s[vector3s.Count - 1] != v4) vector3s.Add(v4);
if (vector3s[vector3s.Count - 1] != v5) vector3s.Add(v5);
if (vector3s[vector3s.Count - 1] != v6) vector3s.Add(v6);
if (vector3s[vector3s.Count - 1] != v7) vector3s.Add(v7);
lineRenderer.positionCount = vector3s.Count;
lineRenderer.SetPositions(vector3s.ToArray());
setBasicInfo(A, B, xian, p, newColor);
}
}
[ContextMenu("同行")]
public void F5()
{
//Creat5(A5, B5);
}
[ContextMenu("6点")]
public void F6()
{
//Creat6(A6, B6, 2);
}
[ContextMenu("批量画线")]
public void F7()
{
for (int i = xianLan.childCount - 1; i >= 0; i--)
{
DestroyImmediate(xianLan.GetChild(i).gameObject);
}
for (int i = 0; i < list7.Count; i++)
{
if (i != 0 && i % 2 != 0)
{
try
{
GameObject go1 = GameManager.Inst.FindParent(list7[i - 1].gameObject, GameManager.Inst.IsDesiredParent);
GameObject go2 = GameManager.Inst.FindParent(list7[i].gameObject, GameManager.Inst.IsDesiredParent);
if (!go1 || !go2) continue;
int cjA = GameManager.Inst.CengJi((go1.GetComponent<DeviceQuery>().deviceList.devicePosition).Split('-')[0]);
int cjB = GameManager.Inst.CengJi((go2.GetComponent<DeviceQuery>().deviceList.devicePosition).Split('-')[0]);
if (cjA == cjB)
{
Creat5(list7[i - 1], list7[i], cjB);
}
else
{
Creat7(list7[i - 1], list7[i], cjB);
}
}
catch (Exception e)
{
Debug.Log("批量画线错误 " + e.Message + e.StackTrace);
}
}
}
}
public override void OnMenuChanged(Menu menu)
{
base.OnMenuChanged(menu);
if (menu == Menu.M_数字孪生_线缆连接_展示 ||
menu == Menu.M_数字孪生_线缆连接_配置 ||
menu == Menu.M_数字孪生_线缆组配置)
{
GameManager.Inst.FindPortPos();
var searchName = GameManager.Inst.search_box.GetComponent<SearchName>();
searchName.LoadXianLan(SearchName.SearchType.线_展示);
//xianLan.gameObject.SetActive(true);
}
else
{
deletxianLan(menu);
}
}
public void deletxianLan(Menu menu)
{
if (menu == Menu.M_数字孪生_线缆连接_展示 ||
menu == Menu.M_数字孪生_线缆连接_配置 ||
menu == Menu.M_数字孪生_线缆组配置)
return;
for (int i = xianLan.childCount - 1; i >= 0; i--)
{
DestroyImmediate(xianLan.GetChild(i).gameObject);
}
//for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
//{
// GameManager.Inst.Cabinets_go[i].GetComponent<TransparentGlow>().F2();
//}
}
}