bool FNiagaraEditor::CanDeleteNodes() const { // If any of the nodes can be deleted then we should allow deleting TSharedPtr<SGraphEditor> CurrentGraphEditor = NodeGraphEditorPtr.Pin(); const FGraphPanelSelectionSet SelectedNodes = CurrentGraphEditor->GetSelectedNodes(); for (FGraphPanelSelectionSet::TConstIterator SelectedIter(SelectedNodes); SelectedIter; ++SelectedIter) { UEdGraphNode* Node = Cast<UEdGraphNode>(*SelectedIter); if (Node && Node->CanUserDeleteNode()) { return true; } } return false; }
void FSoundCueEditor::DeleteSelectedNodes() { const FScopedTransaction Transaction( NSLOCTEXT("UnrealEd", "SoundCueEditorDeleteSelectedNode", "Delete Selected Sound Cue Node") ); SoundCueGraphEditor->GetCurrentGraph()->Modify(); const FGraphPanelSelectionSet SelectedNodes = GetSelectedNodes(); SoundCueGraphEditor->ClearSelectionSet(); for (FGraphPanelSelectionSet::TConstIterator NodeIt(SelectedNodes); NodeIt; ++NodeIt) { UEdGraphNode* Node = CastChecked<UEdGraphNode>(*NodeIt); if (Node->CanUserDeleteNode()) { if (USoundCueGraphNode* SoundGraphNode = Cast<USoundCueGraphNode>(Node)) { USoundNode* DelNode = SoundGraphNode->SoundNode; FBlueprintEditorUtils::RemoveNode(NULL, SoundGraphNode, true); // Make sure SoundCue is updated to match graph SoundCue->CompileSoundNodesFromGraphNodes(); // Remove this node from the SoundCue's list of all SoundNodes SoundCue->AllNodes.Remove(DelNode); SoundCue->MarkPackageDirty(); } else { FBlueprintEditorUtils::RemoveNode(NULL, Node, true); } } } }