UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
EdGraph.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "UObject/Object.h"
8#include "Misc/Guid.h"
9#include "UObject/Class.h"
11#include "Templates/Casts.h"
12#include "EdGraph/EdGraphNode.h"
13#include "BlueprintUtilities.h"
14#include "EdGraph.generated.h"
15
16class UEdGraph;
19
20USTRUCT()
22{
24protected:
25 // Reference to the actual graph
26 UPROPERTY()
27 mutable TObjectPtr<class UEdGraph> MacroGraph;
28
29 // The blueprint the graph is contained within
30 UPROPERTY()
31 TObjectPtr<class UBlueprint> GraphBlueprint;
32
33 // The graph GUID so we can refind it if it has been renamed
34 UPROPERTY()
35 FGuid GraphGuid;
36
37public:
39 : MacroGraph(NULL)
40 , GraphBlueprint(NULL)
41 {
42 }
43
44 ENGINE_API void PostSerialize(const FArchive& Ar);
45
46 class UBlueprint* GetBlueprint() const
47 {
48 return GraphBlueprint;
49 }
50
51#if WITH_EDITORONLY_DATA
52 ENGINE_API void SetGraph(UEdGraph* InGraph);
53 ENGINE_API UEdGraph* GetGraph() const;
54#endif
55};
56
57template<>
59{
60 enum
61 {
63 };
64};
65
66UCLASS(MinimalAPI)
68{
70
71public:
72
74 UPROPERTY()
76
78 UPROPERTY()
80
82 UPROPERTY()
83 uint32 bEditable:1;
84
90 UPROPERTY()
91 uint32 bAllowDeletion:1;
92
94 UPROPERTY()
95 uint32 bAllowRenaming:1;
96
97#if WITH_EDITORONLY_DATA
99 UPROPERTY()
101
103 UPROPERTY()
104 FGuid GraphGuid;
105
107 UPROPERTY()
109#endif // WITH_EDITORONLY_DATA
110
111public:
112 template <typename NodeType> friend struct FGraphNodeCreator;
113
115 ENGINE_API const class UEdGraphSchema* GetSchema() const;
116
118 ENGINE_API FDelegateHandle AddOnGraphChangedHandler( const FOnGraphChanged::FDelegate& InHandler );
119
121 ENGINE_API void RemoveOnGraphChangedHandler( FDelegateHandle Handle );
122
123 //~ Begin UObject interface
124#if WITH_EDITORONLY_DATA
126 ENGINE_API virtual void Serialize(FStructuredArchiveRecord Record) override;
127 ENGINE_API virtual void PostInitProperties() override;
128 ENGINE_API virtual void PostLoad() override;
129 //~ End UObject Interface
130#endif
131
132public:
133
134 template <typename NodeClass>
136 {
137 NodeClass* Node = (NodeClass*)CreateNode(NodeClass::StaticClass());
139 return Node;
140 }
141
148 ENGINE_API virtual void AddNode( UEdGraphNode* NodeToAdd, bool bUserAction = false, bool bSelectNewNode = true );
149
156 ENGINE_API void SelectNodeSet(TSet<const UEdGraphNode*> NodeSelection, bool bFromUI = false);
157
167 ENGINE_API bool RemoveNode( UEdGraphNode* NodeToRemove, bool bBreakAllLinks = true, bool bAlwaysMarkDirty = true );
168
170 ENGINE_API virtual void NotifyGraphChanged();
171
173 ENGINE_API void NotifyNodeChanged(const UEdGraphNode* Node);
174
181 ENGINE_API void MoveNodesToAnotherGraph(UEdGraph* DestinationGraph, bool bIsLoading, bool bInIsCompiling);
182
184 template<class MinRequiredType, class ArrayElementType>
186 {
187 for (int32 i = 0; i < Nodes.Num(); i++)
188 {
189 UEdGraphNode* Node = Nodes[i];
191 {
192 OutNodes.Add(TypedNode);
193 }
194 }
195 }
196
198 template<class MinRequiredType>
203
205 ENGINE_API void GetAllChildrenGraphs(TArray<UEdGraph*>& Graphs) const;
206
208 static ENGINE_API UEdGraph* GetOuterGraph(UObject* Obj);
209
211 ENGINE_API UE::Slate::FDeprecateVector2DResult GetGoodPlaceForNewNode();
212
213#if WITH_EDITOR
215 ENGINE_API void NotifyPreChange( const FString& PropertyName );
216
218 ENGINE_API void NotifyPostChange( const FPropertyChangedEvent& PropertyChangedEvent, const FString& PropertyName );
219
221 ENGINE_API FDelegateHandle AddPropertyChangedNotifier(const FOnPropertyChanged::FDelegate& InDelegate );
222
225#endif
226
227protected:
228 ENGINE_API virtual void NotifyGraphChanged( const FEdGraphEditAction& Action );
229
240
242 {
243 return CreateNode( NewNodeClass, false, bSelectNewNode );
244 }
245
250
251private:
253 FOnGraphChanged OnGraphChanged;
254
255#if WITH_EDITORONLY_DATA
258#endif
259};
260
261
262
273template <typename NodeType>
275{
276public:
278 : Node(NULL), Graph(InGraph), bPlaced(false)
279 {
280 }
281
283 NodeType* CreateNode(bool bSelectNewNode = true, TSubclassOf<NodeType> NodeClass = NodeType::StaticClass())
284 {
285 Node = (NodeType*)Graph.CreateNode(NodeClass, bSelectNewNode);
286 return Node;
287 }
288
290 NodeType* CreateUserInvokedNode(bool bSelectNewNode = true, TSubclassOf<NodeType> NodeClass = NodeType::StaticClass())
291 {
292 Node = (NodeType*)Graph.CreateUserInvokedNode(NodeClass, bSelectNewNode);
293 return Node;
294 }
295
297 void Finalize()
298 {
299 check(!bPlaced);
300 Node->CreateNewGuid();
301 Node->PostPlacedNewNode();
302 bPlaced = true;
303 if (Node->Pins.Num() == 0)
304 {
305 Node->AllocateDefaultPins();
306 }
307 }
308
311 {
312 checkf(bPlaced, TEXT("Created node was not finalized in a FGraphNodeCreator<%s>"), *NodeType::StaticClass()->GetName());
313 }
314
315private:
316 // Hide copy and assignment operator
318 FGraphNodeCreator* operator= (const FGraphNodeCreator& rhs);
319
321 NodeType* Node;
323 UEdGraph& Graph;
325 bool bPlaced;
326};
327
#define NULL
Definition oodle2base.h:134
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition IDelegateInstance.h:14
Definition StructuredArchiveSlots.h:144
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition SubclassOf.h:30
Definition Blueprint.h:403
Definition EdGraphNode.h:289
Definition EdGraphSchema.h:737
Definition EdGraph.h:68
void GetNodesOfClass(TArray< MinRequiredType * > &OutNodes) const
Definition EdGraph.h:199
UEdGraphNode * CreateUserInvokedNode(TSubclassOf< UEdGraphNode > NewNodeClass, bool bSelectNewNode=true)
Definition EdGraph.h:246
NodeClass * CreateIntermediateNode()
Definition EdGraph.h:135
ENGINE_API UEdGraphNode * CreateNode(TSubclassOf< UEdGraphNode > NewNodeClass, bool bFromUI, bool bSelectNewNode)
Definition EdGraph.cpp:216
void GetNodesOfClassEx(TArray< ArrayElementType * > &OutNodes) const
Definition EdGraph.h:185
UEdGraphNode * CreateNode(TSubclassOf< UEdGraphNode > NewNodeClass, bool bSelectNewNode=true)
Definition EdGraph.h:241
Definition Object.h:95
virtual COREUOBJECT_API void BuildSubobjectMapping(UObject *OtherObject, TMap< UObject *, UObject * > &ObjectMapping) const
Definition Obj.cpp:2052
virtual COREUOBJECT_API void PostInitProperties()
Definition UObjectGlobals.cpp:3961
FDeprecateSlateVector2D FDeprecateVector2DResult
Definition SlateVector2.h:469
@ false
Definition radaudio_common.h:23
Definition GraphEditAction.h:29
Definition EdGraph.h:275
FGraphNodeCreator(UEdGraph &InGraph)
Definition EdGraph.h:277
~FGraphNodeCreator()
Definition EdGraph.h:310
NodeType * CreateUserInvokedNode(bool bSelectNewNode=true, TSubclassOf< NodeType > NodeClass=NodeType::StaticClass())
Definition EdGraph.h:290
void Finalize()
Definition EdGraph.h:297
NodeType * CreateNode(bool bSelectNewNode=true, TSubclassOf< NodeType > NodeClass=NodeType::StaticClass())
Definition EdGraph.h:283
Definition EdGraph.h:22
class UBlueprint * GetBlueprint() const
Definition EdGraph.h:46
Definition Guid.h:109
Definition UnrealType.h:6865
Definition EdGraphNode.h:1044
Definition ObjectPtr.h:488
Definition StructOpsTypeTraits.h:11
@ WithPostSerialize
Definition StructOpsTypeTraits.h:25
Definition StructOpsTypeTraits.h:46