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

Reordered node context menu

This commit is contained in:
Thor Kramer Brigsted 2017-11-28 09:41:38 +01:00
parent 215a3475ea
commit 869bd6a76d

View File

@ -80,18 +80,19 @@ namespace XNodeEditor {
/// <summary> Show right-click context menu for a node </summary> /// <summary> Show right-click context menu for a node </summary>
public void ShowNodeContextMenu(Node node) { public void ShowNodeContextMenu(Node node) {
GenericMenu contextMenu = new GenericMenu(); GenericMenu contextMenu = new GenericMenu();
contextMenu.AddItem(new GUIContent("Remove"), false, () => graph.RemoveNode(node));
contextMenu.AddItem(new GUIContent("Duplicate"), false, () => {
Node n = graph.CopyNode(node);
n.position = node.position + new Vector2(30,30);
});
contextMenu.AddItem(new GUIContent("Move To Top"), false, () => { contextMenu.AddItem(new GUIContent("Move To Top"), false, () => {
int index; int index;
while((index = graph.nodes.IndexOf(node)) != graph.nodes.Count-1) { while ((index = graph.nodes.IndexOf(node)) != graph.nodes.Count - 1) {
graph.nodes[index] = graph.nodes[index+1]; graph.nodes[index] = graph.nodes[index + 1];
graph.nodes[index+1] = node; graph.nodes[index + 1] = node;
} }
}); });
contextMenu.AddItem(new GUIContent("Duplicate"), false, () => {
Node n = graph.CopyNode(node);
n.position = node.position + new Vector2(30, 30);
});
contextMenu.AddItem(new GUIContent("Remove"), false, () => graph.RemoveNode(node));
AddCustomContextMenuItems(contextMenu, node); AddCustomContextMenuItems(contextMenu, node);
contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
} }