1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-02-06 15:24:55 +08:00

Added DragToCreate compatible filter

- Added preference to filter the nodes from the draggable context menu, to show only nodes that have ports compatible with the dragged port
- Minor modification in NodeEditorActions, to allow the filter
- Minor modification in NodeGraphEditor to use or not the filter, based in preferences
This commit is contained in:
juliocp 2020-10-07 19:31:07 -03:00
parent 2d91e45dba
commit 37d82ad215
3 changed files with 13 additions and 2 deletions

View File

@ -290,7 +290,7 @@ namespace XNodeEditor
else if (draggedOutputTarget == null && NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null)
{
GenericMenu menu = new GenericMenu();
graphEditor.AddContextMenuItems(menu);
graphEditor.AddContextMenuItems(menu, draggedOutput.ValueType);
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
}
//Release dragged connection

View File

@ -37,6 +37,7 @@ namespace XNodeEditor {
public bool autoSave = true;
public bool openOnCreate = true;
public bool dragToCreate = true;
public bool dragToCreateFilter = true;
public bool zoomToMouse = true;
public bool portTooltips = true;
[SerializeField] private string typeColorsData = "";
@ -166,6 +167,16 @@ namespace XNodeEditor {
settings.noodleStroke = (NoodleStroke) EditorGUILayout.EnumPopup("Noodle stroke", (Enum) settings.noodleStroke);
settings.portTooltips = EditorGUILayout.Toggle("Port Tooltips", settings.portTooltips);
settings.dragToCreate = EditorGUILayout.Toggle(new GUIContent("Drag to Create", "Drag a port connection anywhere on the grid to create and connect a node"), settings.dragToCreate);
//Drag to Create Filter
int oldIndent = EditorGUI.indentLevel;
EditorGUI.indentLevel = oldIndent + 1;
GUI.enabled = settings.dragToCreate;
settings.dragToCreateFilter = EditorGUILayout.Toggle(new GUIContent("Filter", "Only show nodes that are compatible with the dragged port"), settings.dragToCreateFilter);
GUI.enabled = true;
EditorGUI.indentLevel = oldIndent;
//END
if (GUI.changed) {
SavePrefs(key, settings);
NodeEditorWindow.RepaintAll();

View File

@ -77,7 +77,7 @@ namespace XNodeEditor
Type[] nodeTypes = NodeEditorReflection.nodeTypes.OrderBy(type => GetNodeMenuOrder(type)).ToArray();
if (compatibleType != null)
if (compatibleType != null && NodeEditorPreferences.GetSettings().dragToCreateFilter)
{
nodeTypes = NodeEditorUtilities.GetCompatibleNodesTypes(NodeEditorReflection.nodeTypes, compatibleType, direction).ToArray();
}