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:
parent
6d6a6abd9e
commit
1fff90cbf2
@ -159,6 +159,8 @@ namespace XNodeEditor {
|
|||||||
currentActivity = NodeActivity.Idle;
|
currentActivity = NodeActivity.Idle;
|
||||||
} else if (e.button == 1) {
|
} else if (e.button == 1) {
|
||||||
if (!isPanning) {
|
if (!isPanning) {
|
||||||
|
if (IsHoveringPort)
|
||||||
|
ShowPortContextMenu(hoveredPort);
|
||||||
if (IsHoveringNode && IsHoveringTitle(hoveredNode)) {
|
if (IsHoveringNode && IsHoveringTitle(hoveredNode)) {
|
||||||
if (!Selection.Contains(hoveredNode)) SelectNode(hoveredNode, false);
|
if (!Selection.Contains(hoveredNode)) SelectNode(hoveredNode, false);
|
||||||
ShowNodeContextMenu();
|
ShowNodeContextMenu();
|
||||||
|
|||||||
@ -87,6 +87,14 @@ namespace XNodeEditor {
|
|||||||
return GUILayout.Button(name, EditorStyles.toolbarDropDown, GUILayout.Width(width));
|
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>
|
/// <summary> Show right-click context menu for selected nodes </summary>
|
||||||
public void ShowNodeContextMenu() {
|
public void ShowNodeContextMenu() {
|
||||||
GenericMenu contextMenu = new GenericMenu();
|
GenericMenu contextMenu = new GenericMenu();
|
||||||
|
|||||||
@ -127,7 +127,7 @@ namespace XNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Removes all instance ports from the node </summary>
|
/// <summary> Removes all instance ports from the node </summary>
|
||||||
[ContextMenu("Clear instance ports")]
|
[ContextMenu("Clear Instance Ports")]
|
||||||
public void ClearInstancePorts() {
|
public void ClearInstancePorts() {
|
||||||
List<NodePort> instancePorts = new List<NodePort>(InstancePorts);
|
List<NodePort> instancePorts = new List<NodePort>(InstancePorts);
|
||||||
foreach (NodePort port in instancePorts) {
|
foreach (NodePort port in instancePorts) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user