diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs
index 8b671e2..b7ed32d 100644
--- a/Scripts/Editor/NodeGraphEditor.cs
+++ b/Scripts/Editor/NodeGraphEditor.cs
@@ -64,11 +64,24 @@ namespace XNodeEditor
return 0;
}
- /// Add items for the context menu when right-clicking this node. Override to add custom menu items.
- public virtual void AddContextMenuItems(GenericMenu menu)
+ ///
+ /// Add items for the context menu when right-clicking this node.
+ /// Override to add custom menu items.
+ ///
+ ///
+ /// Use it to filter only nodes with ports value type, compatible with this type
+ /// Direction of the compatiblity
+ public virtual void AddContextMenuItems(GenericMenu menu, Type compatibleType = null, XNode.NodePort.IO direction = XNode.NodePort.IO.Input)
{
Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition);
- var nodeTypes = NodeEditorReflection.nodeTypes.OrderBy(type => GetNodeMenuOrder(type)).ToArray();
+
+ Type[] nodeTypes = NodeEditorReflection.nodeTypes.OrderBy(type => GetNodeMenuOrder(type)).ToArray();
+
+ if (compatibleType != null)
+ {
+ nodeTypes = NodeEditorUtilities.GetCompatibleNodesTypes(NodeEditorReflection.nodeTypes, compatibleType, direction).ToArray();
+ }
+
for (int i = 0; i < nodeTypes.Length; i++)
{
Type type = nodeTypes[i];
@@ -101,6 +114,7 @@ namespace XNodeEditor
menu.AddCustomContextMenuItems(target);
}
+
/// Returned gradient is used to color noodles
/// The output this noodle comes from. Never null.
/// The output this noodle comes from. Can be null if we are dragging the noodle.