예제 #1
0
        public GraphNode CreateNode(SerializedNode serializedNode)
        {
            Type         runtimeNodeType = serializedNode.NodeRuntimeType;
            NodeTemplate nodeTemplate    = m_nodeProvider.GetTemplateFromRuntimeType(runtimeNodeType);
            GraphNode    node            = new GraphNode(nodeTemplate.Title.Last(), nodeTemplate.UXMLPath, nodeTemplate.USSPath, runtimeNodeType, m_edgeConnectorListener, serializedNode);

            node.Position = serializedNode.EditorPosition;

            var fieldTemplate = m_fieldProvider.GetNodeFieldTemplateByType(runtimeNodeType);

            for (int j = 0; j < serializedNode.SerializedPorts.Count; j++)
            {
                var sPort = serializedNode.SerializedPorts[j];
                var port  = new PortDescription(sPort.Guid, sPort.DisplayName, sPort.PortType, sPort.Direction, sPort.AllowMultipleConnections, sPort.AddIdenticalPortOnConnect);
                node.AddSlot(port, false);
            }

            foreach (var property in fieldTemplate.Properties)
            {
                node.AddProperty(new VisualProperty(property.FieldType, node.RuntimeInstance));
            }

            node.BindPortsAndProperties();

            return(node);
        }