fix(ConnectionLine):修复AB两点重复连接,有多条连接线,触发重启的BUG
This commit is contained in:
@@ -26,6 +26,16 @@ namespace Script.Gameplay.Connect
|
|||||||
|
|
||||||
public ConnectionLine GenerateConnectionLine(IConnectable a, IConnectable b)
|
public ConnectionLine GenerateConnectionLine(IConnectable a, IConnectable b)
|
||||||
{
|
{
|
||||||
|
// 先检测 a b 点是否已经存在连接线
|
||||||
|
foreach (var aline in a.ConnectionLines)
|
||||||
|
{
|
||||||
|
if (aline.PointA.GetGameObject() == b.GetGameObject() || aline.PointB.GetGameObject() == b.GetGameObject())
|
||||||
|
{
|
||||||
|
Debug.Log("ab点间已经存在连接线");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GameObject lineObject = Instantiate(linePrefab, this.transform);
|
GameObject lineObject = Instantiate(linePrefab, this.transform);
|
||||||
ConnectionLine connectionLine = lineObject.GetComponent<ConnectionLine>();
|
ConnectionLine connectionLine = lineObject.GetComponent<ConnectionLine>();
|
||||||
if (connectionLine != null)
|
if (connectionLine != null)
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ namespace Script.Gameplay.Player
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 创建连接线
|
// 创建连接线
|
||||||
ConnectionLine connectionLine = ConnectionLineManager.Instance.GenerateConnectionLine(outTarget, inputTarget);
|
ConnectionLineManager.Instance.GenerateConnectionLine(outTarget, inputTarget);
|
||||||
|
|
||||||
// 重置信号目标
|
// 重置信号目标
|
||||||
outTarget = null;
|
outTarget = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user