diff --git a/Assets/Scenes/Test.unity b/Assets/Scenes/Test.unity index 1ca72f9..cdbdaf4 100644 --- a/Assets/Scenes/Test.unity +++ b/Assets/Scenes/Test.unity @@ -192,6 +192,18 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 2a2113dbf189fbd44bca90f4df91f338, type: 3} +--- !u!114 &183959152 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 605469399670797709, guid: b3e24e2df98d14e4ebc08cc68c071afa, + type: 3} + m_PrefabInstance: {fileID: 2088331975902746738} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3bdc5380046d4cacb0dd579877f320eb, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &410087039 GameObject: m_ObjectHideFlags: 0 @@ -582,6 +594,86 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b3e24e2df98d14e4ebc08cc68c071afa, type: 3} +--- !u!1001 &1240498723 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalPosition.x + value: -5 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalPosition.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalPosition.z + value: -5 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 502199709937918930, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2052340463965227198, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + propertyPath: m_Name + value: Button (3) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ddd89e93db279184daa80d86bd4e770f, type: 3} +--- !u!114 &1240498724 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 4434834246038522293, guid: ddd89e93db279184daa80d86bd4e770f, + type: 3} + m_PrefabInstance: {fileID: 1240498723} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7f5359facd804a0cb94d416c9c54a167, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1274249800 GameObject: m_ObjectHideFlags: 0 @@ -1412,6 +1504,21 @@ PrefabInstance: propertyPath: m_Name value: ConnectionManager objectReference: {fileID: 0} + - target: {fileID: 6919868315282518728, guid: e6007da0e1121fd4ab3b932c054f6256, + type: 3} + propertyPath: preConnectionLines.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6919868315282518728, guid: e6007da0e1121fd4ab3b932c054f6256, + type: 3} + propertyPath: preConnectionLines.Array.data[0].source + value: + objectReference: {fileID: 1240498724} + - target: {fileID: 6919868315282518728, guid: e6007da0e1121fd4ab3b932c054f6256, + type: 3} + propertyPath: preConnectionLines.Array.data[0].target + value: + objectReference: {fileID: 183959152} - target: {fileID: 8209060139561151121, guid: e6007da0e1121fd4ab3b932c054f6256, type: 3} propertyPath: m_LocalPosition.x @@ -1487,6 +1594,7 @@ SceneRoots: - {fileID: 1781028406820323425} - {fileID: 366996911271636373} - {fileID: 6191742170513974480} + - {fileID: 1240498723} - {fileID: 473911345} - {fileID: 865274353} - {fileID: 6350903300567888677} diff --git a/Assets/Script/Gameplay/Connect/ConnectionLineManager.cs b/Assets/Script/Gameplay/Connect/ConnectionLineManager.cs index bdd336e..e322ff8 100644 --- a/Assets/Script/Gameplay/Connect/ConnectionLineManager.cs +++ b/Assets/Script/Gameplay/Connect/ConnectionLineManager.cs @@ -1,25 +1,58 @@ +using System; using UnityEngine; using System.Collections.Generic; using Core; namespace Script.Gameplay.Connect { + [Serializable] + public class PreviousConnection + { + public int PreConnectionID; + public MonoBehaviour source; + public MonoBehaviour target; + } public class ConnectionLineManager : MonoSingleton { [SerializeField] private GameObject linePrefab; - public List connectionLines = new List(); - + [SerializeField]private List preConnectionLines = new List(); + private List connectionLines = new List(); + + private void Start() + { + GeneratePreviousConnectionLines(preConnectionLines); + } + public ConnectionLine GenerateConnectionLine(IConnectable source, IConnectable target) { GameObject lineObject = Instantiate(linePrefab, this.transform); ConnectionLine connectionLine = lineObject.GetComponent(); if (connectionLine != null) { + source.OutputConnectionLine = connectionLine; + target.InputConnectionLine = connectionLine; connectionLine.SetConnectable(source, target); connectionLines.Add(connectionLine); return connectionLine; } return null; } + + public void GeneratePreviousConnectionLines(List previousConnections) + { + foreach (var preConnection in previousConnections) + { + IConnectable source = preConnection.source as IConnectable; + IConnectable target = preConnection.target as IConnectable; + if (source != null && target != null) + { + GenerateConnectionLine(source, target); + } + else + { + Debug.Log(preConnection.PreConnectionID + " connection failed to load."); + } + } + } } } \ No newline at end of file diff --git a/Assets/Script/Gameplay/Player/PlayerConnectController.cs b/Assets/Script/Gameplay/Player/PlayerConnectController.cs index d14c7f3..f804bdb 100644 --- a/Assets/Script/Gameplay/Player/PlayerConnectController.cs +++ b/Assets/Script/Gameplay/Player/PlayerConnectController.cs @@ -121,8 +121,7 @@ namespace Script.Gameplay.Player } // 创建连接线 ConnectionLine connectionLine = ConnectionLineManager.Instance.GenerateConnectionLine(outTarget, inputTarget); - outTarget.OutputConnectionLine = connectionLine; - inputTarget.InputConnectionLine = connectionLine; + // 重置信号目标 outTarget = null; inputTarget = null;