private void CreateNodeFromMenu(Type type, Vector2 pos, NodePort draggedOutput) { CreateNode(type, pos, node => { node.name = NodeName(type); // Try connect created node to current dragged output if (draggedOutput != null) { foreach (NodePort input in node.Inputs) { if (draggedOutput.CanConnectTo(input)) { draggedOutput.Connect(input); break; } } } }); }