UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InheritableComponentHandler.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4#pragma once
5
6#include "CoreMinimal.h"
8#include "UObject/Object.h"
9#include "Misc/Guid.h"
11#include "InheritableComponentHandler.generated.h"
12
13class UActorComponent;
14class UBlueprint;
15class USCS_Node;
16struct FUCSComponentId;
17
18USTRUCT()
20{
22
24 : OwnerClass(nullptr)
25 {}
26
28#if WITH_EDITOR
30#endif
31
32 ENGINE_API bool Match(const FComponentKey& OtherKey) const;
33
34 bool IsSCSKey() const
35 {
36 return (SCSVariableName != NAME_None) && AssociatedGuid.IsValid();
37 }
38
39 bool IsUCSKey() const
40 {
41 return AssociatedGuid.IsValid() && (SCSVariableName == NAME_None);
42 }
43
44 bool IsValid() const
45 {
46 return OwnerClass && AssociatedGuid.IsValid() && (!IsSCSKey() || (SCSVariableName != NAME_None));
47 }
48
49 ENGINE_API USCS_Node* FindSCSNode() const;
50 ENGINE_API UActorComponent* GetOriginalTemplate(const FName& TemplateName = NAME_None) const;
51 ENGINE_API bool RefreshVariableName();
52
53 UClass* GetComponentOwner() const { return OwnerClass; }
54 FName GetSCSVariableName() const { return SCSVariableName; }
55 FGuid GetAssociatedGuid() const { return AssociatedGuid; }
56
57private:
58 UPROPERTY()
59 TObjectPtr<UClass> OwnerClass;
60
61 UPROPERTY()
62 FName SCSVariableName;
63
64 UPROPERTY()
65 FGuid AssociatedGuid;
66};
67
68USTRUCT()
70{
72
73 UPROPERTY()
74 TObjectPtr<UClass> ComponentClass;
75
76 UPROPERTY()
77 TObjectPtr<UActorComponent> ComponentTemplate;
78
79 UPROPERTY()
80 FComponentKey ComponentKey;
81
82 UPROPERTY()
83 FBlueprintCookedComponentInstancingData CookedComponentInstancingData;
84
86 : ComponentClass(nullptr)
87 , ComponentTemplate(nullptr)
88 {}
89};
90
91UCLASS(MinimalAPI)
93{
95
96private:
97
98 /* Template name prefix for SCS DefaultSceneRootNode overrides */
99 static ENGINE_API const FString SCSDefaultSceneRootOverrideNamePrefix;
100
101#if WITH_EDITOR
102
105
106public:
107
112 ENGINE_API bool IsValid() const;
114
115 bool IsEmpty() const
116 {
117 return 0 == Records.Num();
118 }
119
121
122 ENGINE_API FComponentKey FindKey(UActorComponent* ComponentTemplate) const;
123#endif
124
125public:
126
127 //~ Begin UObject Interface
128 ENGINE_API virtual void Serialize(FArchive& Ar) override;
129#if WITH_EDITOR
130 ENGINE_API virtual EDataValidationResult IsDataValid(class FDataValidationContext& Context) const override;
131#endif // WITH_EDITOR
132 //~ End UObject Interface
133
134 ENGINE_API void PreloadAllTemplates();
135 ENGINE_API void PreloadAll();
136
137 ENGINE_API FComponentKey FindKey(const FName VariableName) const;
138
139 ENGINE_API UActorComponent* GetOverridenComponentTemplate(const FComponentKey& Key) const;
140 ENGINE_API const FBlueprintCookedComponentInstancingData* GetOverridenComponentTemplateData(const FComponentKey& Key) const;
141
146
148 {
149 OutArray.Reserve(OutArray.Num() + Records.Num() + (bIncludeTransientTemplates ? UnnecessaryComponents.Num() : 0));
150 for (const FComponentOverrideRecord& Record : Records)
151 {
152 OutArray.Add(Record.ComponentTemplate);
153 }
154
156 {
157 OutArray.Append(UnnecessaryComponents);
158 }
159 }
160
161private:
162 ENGINE_API const FComponentOverrideRecord* FindRecord(const FComponentKey& Key) const;
163
165 ENGINE_API void FixComponentTemplateName(UActorComponent* ComponentTemplate, FName NewName);
166
167 void FixComponentTemplateNames();
168
170 UPROPERTY()
172
175 TArray<TObjectPtr<UActorComponent>> UnnecessaryComponents;
176};
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_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
EDataValidationResult
Definition UObjectGlobals.h:4225
Definition Archive.h:1208
Definition DataValidation.h:40
Definition NameTypes.h:617
Definition Array.h:670
UE_NODEBUG TIterator CreateIterator()
Definition Array.h:3355
Definition Array.h:64
Definition ActorComponent.h:152
Definition BlueprintGeneratedClass.h:433
Definition Blueprint.h:403
Definition Class.h:3793
Definition InheritableComponentHandler.h:93
TArray< FComponentOverrideRecord >::TIterator CreateRecordIterator()
Definition InheritableComponentHandler.h:142
void GetAllTemplates(TArray< UActorComponent * > &OutArray, bool bIncludeTransientTemplates=false) const
Definition InheritableComponentHandler.h:147
Definition Object.h:95
Definition SCS_Node.h:21
Definition BlueprintGeneratedClass.h:345
Definition InheritableComponentHandler.h:20
bool IsUCSKey() const
Definition InheritableComponentHandler.h:39
UClass * GetComponentOwner() const
Definition InheritableComponentHandler.h:53
FName GetSCSVariableName() const
Definition InheritableComponentHandler.h:54
bool IsValid() const
Definition InheritableComponentHandler.h:44
FGuid GetAssociatedGuid() const
Definition InheritableComponentHandler.h:55
bool IsSCSKey() const
Definition InheritableComponentHandler.h:34
Definition InheritableComponentHandler.h:70
Definition Guid.h:109
Definition ObjectPtr.h:488