1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

# Expanded the disconnect Menu Items of <NodePort>

This commit is contained in:
mayuntian 2020-08-07 18:50:23 +08:00
parent 60a8e89cdb
commit abb4ea8208

View File

@ -112,6 +112,11 @@ namespace XNodeEditor {
/// <summary> Show right-click context menu for hovered port </summary> /// <summary> Show right-click context menu for hovered port </summary>
void ShowPortContextMenu(XNode.NodePort hoveredPort) { void ShowPortContextMenu(XNode.NodePort hoveredPort) {
GenericMenu contextMenu = new GenericMenu(); GenericMenu contextMenu = new GenericMenu();
foreach (var port in hoveredPort.GetConnections()) {
var name = port.node.name;
var index = hoveredPort.GetConnectionIndex(port);
contextMenu.AddItem(new GUIContent($"Disconnect({name})"), false, () => hoveredPort.Disconnect(index));
}
contextMenu.AddItem(new GUIContent("Clear Connections"), false, () => hoveredPort.ClearConnections()); contextMenu.AddItem(new GUIContent("Clear Connections"), false, () => hoveredPort.ClearConnections());
contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();