mirror of
https://github.com/Siccity/xNode.git
synced 2026-02-14 11:01:37 +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:
parent
2d91e45dba
commit
37d82ad215
@ -290,7 +290,7 @@ namespace XNodeEditor
|
|||||||
else if (draggedOutputTarget == null && NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null)
|
else if (draggedOutputTarget == null && NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null)
|
||||||
{
|
{
|
||||||
GenericMenu menu = new GenericMenu();
|
GenericMenu menu = new GenericMenu();
|
||||||
graphEditor.AddContextMenuItems(menu);
|
graphEditor.AddContextMenuItems(menu, draggedOutput.ValueType);
|
||||||
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
||||||
}
|
}
|
||||||
//Release dragged connection
|
//Release dragged connection
|
||||||
|
|||||||
@ -37,6 +37,7 @@ namespace XNodeEditor {
|
|||||||
public bool autoSave = true;
|
public bool autoSave = true;
|
||||||
public bool openOnCreate = true;
|
public bool openOnCreate = true;
|
||||||
public bool dragToCreate = true;
|
public bool dragToCreate = true;
|
||||||
|
public bool dragToCreateFilter = true;
|
||||||
public bool zoomToMouse = true;
|
public bool zoomToMouse = true;
|
||||||
public bool portTooltips = true;
|
public bool portTooltips = true;
|
||||||
[SerializeField] private string typeColorsData = "";
|
[SerializeField] private string typeColorsData = "";
|
||||||
@ -166,6 +167,16 @@ namespace XNodeEditor {
|
|||||||
settings.noodleStroke = (NoodleStroke) EditorGUILayout.EnumPopup("Noodle stroke", (Enum) settings.noodleStroke);
|
settings.noodleStroke = (NoodleStroke) EditorGUILayout.EnumPopup("Noodle stroke", (Enum) settings.noodleStroke);
|
||||||
settings.portTooltips = EditorGUILayout.Toggle("Port Tooltips", settings.portTooltips);
|
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);
|
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) {
|
if (GUI.changed) {
|
||||||
SavePrefs(key, settings);
|
SavePrefs(key, settings);
|
||||||
NodeEditorWindow.RepaintAll();
|
NodeEditorWindow.RepaintAll();
|
||||||
|
|||||||
@ -77,7 +77,7 @@ namespace XNodeEditor
|
|||||||
|
|
||||||
Type[] nodeTypes = NodeEditorReflection.nodeTypes.OrderBy(type => GetNodeMenuOrder(type)).ToArray();
|
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();
|
nodeTypes = NodeEditorUtilities.GetCompatibleNodesTypes(NodeEditorReflection.nodeTypes, compatibleType, direction).ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user