Hello! I’m trying to create a plugin and recently I created comment, but the text doesn’t update in it. I didn’t find any documentation or my mistake.
USTRUCT()
struct FLogSystemComment_SchemaAction : public FEdGraphSchemaAction
{
GENERATED_USTRUCT_BODY();
FLogSystemComment_SchemaAction() : FEdGraphSchemaAction() {}
FLogSystemComment_SchemaAction(FText InNodeCategory, FText InMenuDesc, FText InToolTip, int32 InGrouping)
: FEdGraphSchemaAction(InNodeCategory, InMenuDesc, InToolTip, InGrouping) {}
//~ Begin FEdGraphSchemaAction Interface
UEdGraphNode* PerformAction(UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override;
//~ End FEdGraphSchemaAction Interface
};
–
UEdGraphNode* FLogSystemComment_SchemaAction::PerformAction(UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode/= true/)
{
UEdGraphNode_Comment* const CommentTemplate = NewObject<UEdGraphNode_Comment>();
FVector2D SpawnLocation = Location;
FSlateRect Bounds;
TSharedPtr<SGraphEditor> GraphEditorPtr = SGraphEditor::FindGraphEditorForGraph(ParentGraph);
if (GraphEditorPtr.IsValid() && GraphEditorPtr->GetBoundsForSelectedNodes(/*out*/ Bounds, 50.0f))
{
CommentTemplate->SetBounds(Bounds);
SpawnLocation.X = CommentTemplate->NodePosX;
SpawnLocation.Y = CommentTemplate->NodePosY;
}
UEdGraphNode* const NewNode = FEdGraphSchemaAction_NewNode::SpawnNodeFromTemplate<UEdGraphNode_Comment>(ParentGraph, CommentTemplate, SpawnLocation, bSelectNewNode);
return NewNode;
}
void ULogSystem_GraphSchema::GetGraphContextActions(FGraphContextMenuBuilder& ContextMenuBuilder) const
{
ULogSystem_General* Graph = CastChecked<ULogSystem_General>(ContextMenuBuilder.CurrentGraph->GetOuter());
// GetCommentAction(ContextMenuBuilder, ContextMenuBuilder.CurrentGraph);
if (Graph->NodeType == nullptr)
{
return;
}
const bool bNoParent = (ContextMenuBuilder.FromPin == NULL);
FText MenuDescription = LOCTEXT("AddCommentAction", "Add Comment...");
FText ToolTip = LOCTEXT("CreateCommentToolTip", "Creates a comment.");
constexpr int32 Grouping = 1;
TSharedPtr<FLogSystemComment_SchemaAction> NewAction(new FLogSystemComment_SchemaAction(LOCTEXT("GraphAction", "Graph"), MenuDescription, ToolTip, Grouping));
ContextMenuBuilder.AddAction(NewAction);
}
void FLogSystem_AssetEditor::CreateCommandList()
{
if (GraphEditorCommands.IsValid())
{
return;
}
GraphEditorCommands = MakeShareable(new FUICommandList);
GraphEditorCommands->MapAction(FGraphEditorCommands::Get().CreateComment, FExecuteAction::CreateLambda([this]
{
FLogSystemComment_SchemaAction CommentAction;
TSharedPtr<SGraphEditor> CurrentGraphEditor = GetCurrGraphEditor();
CommentAction.PerformAction(LogSystemAsset->EdGraph, nullptr, CurrentGraphEditor->GetPasteLocation());
})
);