mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Added 'Clear Connections' right-click option for NodePorts
This commit is contained in:
parent
6d6a6abd9e
commit
1fff90cbf2
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user