public void OnDisable()
        {
            if (cursorDragLink != null)
            {
                cursorDragLink.DraggedLinkReleased -= HandleMouseDraggedLinkReleased;
                cursorDragLink.Destroy();
                cursorDragLink = null;
            }

            RemoveGraphListeners();

            if (selectionBox != null)
            {
                selectionBox.SelectionPerformed -= HandleBoxSelection;
            }
            if (cursorDragLink != null)
            {
                cursorDragLink.DraggedLinkReleased -= HandleMouseDraggedLinkReleased;
            }
            if (contextMenu != null)
            {
                contextMenu.RequestContextMenuCreation -= OnRequestContextMenuCreation;
                contextMenu.MenuItemClicked            -= OnMenuItemClicked;
            }
            Undo.undoRedoPerformed -= OnUndoRedoPerformed;

            // TODO: Check if we need to un-subscribe from the events registered in OnEnable
        }
        public void OnEnable()
        {
            hideFlags = HideFlags.HideAndDontSave;
            if (camera == null)
            {
                camera = new GraphCamera();
            }
            if (selectionBox == null)
            {
                selectionBox = new GraphSelectionBox();
                selectionBox.SelectionPerformed += HandleBoxSelection;
            }
            if (keyboardState == null)
            {
                keyboardState = new KeyboardState();
            }
            if (cursorDragLink == null)
            {
                cursorDragLink = new CursorDragLink(this);
                cursorDragLink.DraggedLinkReleased += HandleMouseDraggedLinkReleased;
            }
            if (contextMenu == null)
            {
                contextMenu = new GraphContextMenu();
                contextMenu.RequestContextMenuCreation += OnRequestContextMenuCreation;
                contextMenu.MenuItemClicked            += OnMenuItemClicked;
            }

            RemoveGraphListeners();
            AddGraphListeners();

            InitializeNodeRenderers();

            Undo.undoRedoPerformed += OnUndoRedoPerformed;
        }
 public void OnDestroy()
 {
     if (cursorDragLink != null)
     {
         cursorDragLink.Destroy();
         cursorDragLink = null;
     }
 }