UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ChildActorComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4#pragma once
5
9
10#include "ChildActorComponent.generated.h"
11
12class AActor;
13
14USTRUCT()
26
27USTRUCT()
29{
31public:
33 ENGINE_API FChildActorComponentInstanceData(const class UChildActorComponent* Component);
34
36
37 ENGINE_API virtual bool ContainsData() const override;
38
39 ENGINE_API virtual void ApplyToComponent(UActorComponent* Component, const ECacheApplyPhase CacheApplyPhase) override;
40 ENGINE_API virtual void AddReferencedObjects(FReferenceCollector& Collector) override;
41
42 // The class of the child actor when the instance data cache was stored
43 UPROPERTY()
44 TSubclassOf<AActor> ChildActorClass;
45
46 // The name of the spawned child actor so it (attempts to) remain constant across construction script reruns
47 UPROPERTY()
48 FName ChildActorName;
49
50 UPROPERTY()
52
53#if WITH_EDITOR
56#endif
57
58 // The saved properties for the ChildActor itself
60
61 // The component instance data cache for the ChildActor spawned by this component
63};
64
65#if WITH_EDITORONLY_DATA
66UENUM()
68{
78 Hidden,
79};
80#endif
81
83UCLASS(ClassGroup=Utility, hidecategories=(Object,LOD,Physics,Lighting,TextureStreaming,Activation,"Components|Activation",Collision), meta=(BlueprintSpawnableComponent), MinimalAPI)
84class UChildActorComponent : public USceneComponent
85{
87
88
94 UFUNCTION(BlueprintCallable, Category=ChildActorComponent)
96 {
98 }
99
111
112 TSubclassOf<AActor> GetChildActorClass() const { return ChildActorClass; }
113
114 friend class FChildActorComponentDetails;
115
116private:
118 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=ChildActorComponent, meta=(OnlyPlaceable, AllowPrivateAccess="true", ForceRebuildProperty="ChildActorTemplate"))
119 TSubclassOf<AActor> ChildActorClass;
120
122 UPROPERTY(Replicated, BlueprintReadOnly, ReplicatedUsing=OnRep_ChildActor, Category=ChildActorComponent, TextExportTransient, DuplicateTransient, meta=(AllowPrivateAccess="true"))
124
126 UPROPERTY(VisibleDefaultsOnly, DuplicateTransient, Category=ChildActorComponent, meta=(ShowInnerProperties))
128
130 FName ChildActorName;
131
134
137
138#if WITH_EDITORONLY_DATA
140 UPROPERTY()
142#endif
143
148 UPROPERTY(EditDefaultsOnly, Category=ChildActorComponent)
150
154 UPROPERTY(EditDefaultsOnly, Category=ChildActorComponent)
156
159
162
163#if WITH_EDITOR
164 ENGINE_API virtual void SetPackageExternal(bool bExternal, bool bShouldDirty) override;
165#endif
166
167public:
168
170
171 //~ Begin Object Interface.
172#if WITH_EDITOR
173 ENGINE_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
174 ENGINE_API virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override;
175 ENGINE_API virtual void PostEditImport() override;
176 ENGINE_API virtual void PostEditUndo() override;
177 ENGINE_API virtual void PostLoad() override;
178 ENGINE_API virtual EDataValidationResult IsDataValid(class FDataValidationContext& Context) const override;
179#endif
180 ENGINE_API virtual void Serialize(FArchive& Ar) override;
181 ENGINE_API virtual void BeginDestroy() override;
182 ENGINE_API virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
183 ENGINE_API virtual void PostRepNotifies() override;
184 static ENGINE_API void AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector);
185 //~ End Object Interface.
186
187 //~ Begin ActorComponent Interface.
188 ENGINE_API virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override;
189 ENGINE_API virtual void OnRegister() override;
190 ENGINE_API virtual void OnUnregister() override;
191 ENGINE_API virtual TStructOnScope<FActorComponentInstanceData> GetComponentInstanceData() const override;
192 ENGINE_API virtual void BeginPlay() override;
193 ENGINE_API virtual bool IsHLODRelevant() const override;
194#if WITH_EDITOR
196#endif
197 //~ End ActorComponent Interface.
198
200 ENGINE_API void ApplyComponentInstanceData(FChildActorComponentInstanceData* ComponentInstanceData, const ECacheApplyPhase CacheApplyPhase);
201
203 ENGINE_API virtual void CreateChildActor(TFunction<void(AActor*)> CustomizerFunc = nullptr);
204
205 DECLARE_EVENT_OneParam(UChildActorComponent, FOnChildActorCreated, AActor*);
207
208 AActor* GetChildActor() const { return ChildActor; }
211
212 FName GetChildActorName() const { return ChildActorName; }
213 ENGINE_API void SetChildActorName(const FName InName);
214
217
220
221#if WITH_EDITOR
223 {
225 }
226
228#endif
229
231 ENGINE_API virtual void RegisterReplicationFragments(UE::Net::FFragmentRegistrationContext& Context, UE::Net::EFragmentRegistrationFlags RegistrationFlags) override;
232
233
234private:
236
237 ENGINE_API bool IsLevelBeingRemoved() const;
238
239 UFUNCTION()
241
243
244 UFUNCTION()
246
248};
249
251{
252 static void Set(AActor* ChildActor, UChildActorComponent* ParentComponent);
253private:
254 friend UChildActorComponent;
255};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
ECacheApplyPhase
Definition ComponentInstanceDataCache.h:18
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_EVENT_OneParam(OwningType, EventName, Param1Type)
Definition DelegateCombinations.h:51
return true
Definition ExternalRpcRegistry.cpp:601
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UMETA(...)
Definition ObjectMacros.h:747
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
EDataValidationResult
Definition UObjectGlobals.h:4225
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Actor.h:257
static ENGINE_API void AddReferencedObjects(UObject *InThis, FReferenceCollector &Collector)
Definition Actor.cpp:567
Definition Archive.h:1208
Definition DataValidation.h:40
Definition NameTypes.h:617
Definition UObjectGlobals.h:2492
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition SharedPointer.h:692
Definition StructOnScope.h:142
Definition SubclassOf.h:30
Definition ActorComponent.h:152
Definition ReplicationFragment.h:244
Definition Object.h:95
EFragmentRegistrationFlags
Definition ReplicationFragment.h:220
Definition ChildActorComponent.h:251
Definition ChildActorComponent.h:16
Definition ChildActorComponent.h:29
virtual ~FChildActorComponentInstanceData()=default
TSharedPtr< FActorInstanceData > ActorInstanceData
Definition ChildActorComponent.h:59
TSharedPtr< FComponentInstanceDataCache > ComponentInstanceData
Definition ChildActorComponent.h:62
ENGINE_API FChildActorComponentInstanceData(const class UChildActorComponent *Component)
Definition Guid.h:109
Definition UnrealType.h:7001
Definition UnrealType.h:6865
Definition SceneComponent.h:1743
Definition ObjectPtr.h:488
Definition WeakObjectPtrTemplates.h:25