private static FlowOutPortConfigInfo ConvertToFlowOutPortInfo(FlowOutPortEditorView flowOutPort) { FlowOutPortConfigInfo flowOutPortConfigInfo = new FlowOutPortConfigInfo(); flowOutPortConfigInfo.flowOutPortName = flowOutPort.flowoutPortAttribute.portName; flowOutPortConfigInfo.targetNodeList = new List <int>(); for (int i = 0; i < flowOutPort.connectedPortList.Count; i++) { int connectedNodeId = flowOutPort.connectedPortList[i].NodeView.NodeId; flowOutPortConfigInfo.targetNodeList.Add(connectedNodeId); } return(flowOutPortConfigInfo); }
private static void UpdateNodeViewData(NodeConfigInfo nodeConfigInfo, NodeEditorView nodeView, GraphEditorData data) { //flow in port--处理流出节点的时候顺便就处理了 //flow out port for (int i = 0; i < nodeConfigInfo.flowOutPortInfoList.Count; i++) { FlowOutPortConfigInfo flowOutPortConfigInfo = nodeConfigInfo.flowOutPortInfoList[i]; FlowOutPortEditorView flowOutPortView = GetFlowOutPortViewByPortName(nodeView.flowOutPortViews, flowOutPortConfigInfo.flowOutPortName); if (flowOutPortView == null) { Debug.LogFormat("节点{0}中找不到流出端口 <{1}> 了,该端口的连接被忽略", nodeView.ReflectionInfo.Type, flowOutPortConfigInfo.flowOutPortName); continue; } for (int j = 0; j < flowOutPortConfigInfo.targetNodeList.Count; j++) { int targetNodeId = flowOutPortConfigInfo.targetNodeList[j]; NodeEditorView targetNodeView = data.GetNode(targetNodeId); if (targetNodeView == null) { Debug.LogErrorFormat("无法找到节点{0},可能是配置损坏/更改了类名...", targetNodeId); continue; } if (targetNodeView.flowInPortView == null) { Debug.LogErrorFormat("节点类型{0}没有流入节点,是否节点性质发生了改变?", nodeView.ReflectionInfo.Type.FullName); continue; } ConnectionLineView connectionLineView = new ConnectionLineView(flowOutPortView, targetNodeView.flowInPortView, data); data.connectionLineList.Add(connectionLineView); } } //output port -- 不用配置 //input port for (int i = 0; i < nodeConfigInfo.inputPortInfoList.Count; i++) { InputPortConfigInfo inputPortConfigInfo = nodeConfigInfo.inputPortInfoList[i]; InputPortEditorView inputPortView = GetInputPortViewByPortName(nodeView.inputPortViewList, inputPortConfigInfo.portName); if (inputPortView == null) { Debug.LogFormat("节点{0}中无法找到接口名字为 <{1}> 的NodeInputVariable Field,该接口配置被跳过", nodeView.ReflectionInfo.Type.FullName, inputPortConfigInfo.portName); continue; } //没有连接到其他节点的情况 if (string.IsNullOrEmpty(inputPortConfigInfo.targetPortName)) { //设置默认值 Type valueType = Type.GetType(inputPortConfigInfo.nodeVariableGenericTypeName); if (valueType == null) { valueType = Type.GetType(inputPortConfigInfo.nodeVariableGenericTypeName + ",UnityEngine"); if (valueType == null) { valueType = Type.GetType(inputPortConfigInfo.nodeVariableGenericTypeName + ",Assembly-CSharp"); } } if (valueType == null) { Debug.LogErrorFormat("工程中找不到类型: {0}", inputPortConfigInfo.nodeVariableGenericTypeName); continue; } SetNodeInputVariableValue(inputPortView.inputPortReflectionInfo, valueType, inputPortConfigInfo.nodeVariableValue, nodeView); } //连接到其他节点的情况 else { NodeEditorView connectedToNodeView = data.GetNode(inputPortConfigInfo.targetNodeId); if (connectedToNodeView == null) { Debug.LogErrorFormat("节点 {0} 的input接口 {1} 找不到连接的节点{2}", nodeView.NodeId, inputPortConfigInfo.portName, inputPortConfigInfo.targetNodeId); continue; } OutputPortEditorView connectedToOutputPortView = GetOutputPortViewByPortName(connectedToNodeView.outputPortViewList, inputPortConfigInfo.targetPortName); if (connectedToOutputPortView == null) { Debug.LogFormat("找不到节点{0}中 接口名字为 <{1}> 的output接口,该接口的连接被跳过", connectedToNodeView.NodeId, inputPortConfigInfo.targetPortName); continue; } ConnectionLineView connectionLineView = new ConnectionLineView(inputPortView, connectedToOutputPortView, data); data.connectionLineList.Add(connectionLineView); } } }