using System.Collections; using System.Collections.Generic; using UnityEngine; using XFramework; using XNode; public class UseNode : MonoBehaviour { public string processName; //拆卸流程 NodeGraph procress; Dictionary> keyValues = new Dictionary>(); // Start is called before the first frame update void Start() { procress = Resources.Load("NodeGraph/" + processName); for (int i = 0; i < procress.nodes.Count; i++) { foreach (NodePort item in procress.nodes[i].Outputs) { if (item.IsConnected) { string nodeName = (string)item.node.GetValue(null); if (keyValues.ContainsKey(nodeName)) { Debug.LogError($"存在重复的步骤名称{nodeName},跳过重复节点"); continue; } keyValues.Add(nodeName, new List()); List Connections = item.GetConnections();//获取当前节点 后续的所有节点 for (int j = 0; j < Connections.Count; j++) { keyValues[nodeName].Add((string)Connections[j].node.GetValue(null)); } } } } foreach (var item in keyValues) { for (int i = 0; i < item.Value.Count; i++) { Debug.Log($"{item.Key}___{item.Value[i]}"); } } } }