1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-21 01:36:03 +08:00

Added 'Clear Connections' right-click option for NodePorts

This commit is contained in:
Thor Brigsted 2018-03-28 00:55:53 +02:00
parent 6d6a6abd9e
commit 1fff90cbf2
3 changed files with 11 additions and 1 deletions

View File

@ -159,6 +159,8 @@ namespace XNodeEditor {
currentActivity = NodeActivity.Idle;
} else if (e.button == 1) {
if (!isPanning) {
if (IsHoveringPort)
ShowPortContextMenu(hoveredPort);
if (IsHoveringNode && IsHoveringTitle(hoveredNode)) {
if (!Selection.Contains(hoveredNode)) SelectNode(hoveredNode, false);
ShowNodeContextMenu();

View File

@ -87,6 +87,14 @@ namespace XNodeEditor {
return GUILayout.Button(name, EditorStyles.toolbarDropDown, GUILayout.Width(width));
}
/// <summary> Show right-click context menu for hovered port </summary>
void ShowPortContextMenu(XNode.NodePort hoveredPort) {
GenericMenu contextMenu = new GenericMenu();
contextMenu.AddItem(new GUIContent("Clear Connections"), false, () => hoveredPort.ClearConnections());
contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
AssetDatabase.SaveAssets();
}
/// <summary> Show right-click context menu for selected nodes </summary>
public void ShowNodeContextMenu() {
GenericMenu contextMenu = new GenericMenu();

View File

@ -127,7 +127,7 @@ namespace XNode {
}
/// <summary> Removes all instance ports from the node </summary>
[ContextMenu("Clear instance ports")]
[ContextMenu("Clear Instance Ports")]
public void ClearInstancePorts() {
List<NodePort> instancePorts = new List<NodePort>(InstancePorts);
foreach (NodePort port in instancePorts) {