UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PropertyAccess.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"
8#include "UObject/Object.h"
9
10#include "PropertyAccess.generated.h"
11
14enum class EPropertyAccessType : uint8;
15
16// The various types of property copy
17UENUM()
19{
20 // A copy of internal->internal data, unbatched
22
23 // A copy of external->internal data, unbatched
25
26 // A copy of internal->internal data, batched
28
29 // A copy of external->internal data, batched
31
32 Count
33};
34
35namespace PropertyAccess
36{
39 {
41 : Id(InId)
42 {}
43
45 };
46
47
48 UE_DEPRECATED(5.0, "Please use PatchPropertyOffsets instead")
50
56
62
63 UE_DEPRECATED(5.0, "Please use the signature that takes a FCopyBatchId BatchId")
65
71
72 UE_DEPRECATED(5.0, "Please use the signature that takes a FCopyBatchId BatchId")
74
75 UE_DEPRECATED(5.0, "Property Access Events are no longer supported")
77
78 UE_DEPRECATED(5.0, "Property Access Events are no longer supported")
80
83}
84
85// The type of an indirection
86UENUM()
88{
89 // Access node is a simple basePtr + offset
90 Offset,
91
92 // Access node needs to dereference an object at its current address
93 Object,
94
95 // Access node indexes a dynamic array
96 Array,
97
98 // Access node calls a script function to get a value
100
101 // Access node calls a native function to get a value
103};
104
105// For object nodes, we need to know what type of object we are looking at so we can cast appropriately
106UENUM()
108{
109 // Access is not an object
110 None,
111
112 // Access is an object
113 Object,
114
115 // Access is a weak object
117
118 // Access is a soft object
120};
121
122// Runtime-generated access node.
123// Represents:
124// - An offset within an object
125// - An indirection to follow (object, array, function)
126USTRUCT()
128{
130
132
133private:
135
136 // Property of this indirection. Used for arrays and functions (holds the return value property for functions)
137 UPROPERTY()
139
140 // Function if this is a script of native function indirection
141 UPROPERTY()
142 TObjectPtr<UFunction> Function = nullptr;
143
144 // Return buffer size if this is a script of native function indirection
145 UPROPERTY()
146 int32 ReturnBufferSize = 0;
147
148 // Return buffer alignment if this is a script of native function indirection
149 UPROPERTY()
150 int32 ReturnBufferAlignment = 0;
151
152 // Array index if this is an array indirection
153 UPROPERTY()
154 int32 ArrayIndex = INDEX_NONE;
155
156 // Offset of this indirection within its containing object
157 UPROPERTY()
158 uint32 Offset = 0;
159
160 // Object type if this is an object indirection
161 UPROPERTY()
163
164 // The type of this indirection
165 UPROPERTY()
167};
168
169// A single property access list. This is a list of FPropertyAccessIndirection
170USTRUCT()
172{
174
176
177private:
179
180 // Leaf property
181 UPROPERTY()
182 TFieldPath<FProperty> Property = nullptr;
183
184 // Index of the first indirection of a property access
185 UPROPERTY()
186 int32 IndirectionStartIndex = INDEX_NONE;
187
188 // Index of the last indirection of a property access
189 UPROPERTY()
190 int32 IndirectionEndIndex = INDEX_NONE;
191};
192
193// Flags for a segment of a property access path
194// Note: NOT an UENUM as we dont support mixing flags and values properly in UENUMs, e.g. for serialization.
196{
197 // Segment has not been resolved yet, we don't know anything about it
198 Unresolved = 0,
199
200 // Segment is a struct property
201 Struct,
202
203 // Segment is a leaf property
204 Leaf,
205
206 // Segment is an object
207 Object,
208
209 // Segment is a weak object
211
212 // Segment is a soft object
214
215 // Segment is a dynamic array. If the index is INDEX_NONE, then the entire array is referenced.
216 Array,
217
218 // Segment is a dynamic array of structs. If the index is INDEX_NONE, then the entire array is referenced.
220
221 // Segment is a dynamic array of objects. If the index is INDEX_NONE, then the entire array is referenced.
223
224 // Entries before this are exclusive values
226
227 // Segment is a function
228 Function = (1 << 15),
229
230 // All modifier flags
232};
233
235
236// A segment of a 'property path' used to access an object's properties from another location
237USTRUCT()
239{
241
243
244private:
246 friend struct FPropertyAccessEditorSystem;
247
249 UPROPERTY()
251
253 UPROPERTY()
254 TObjectPtr<UStruct> Struct = nullptr;
255
257 UPROPERTY()
259
261 UPROPERTY()
262 TObjectPtr<UFunction> Function = nullptr;
263
265 UPROPERTY()
266 int32 ArrayIndex = INDEX_NONE;
267
269 UPROPERTY()
271};
272
273// A property access path. References a string of property access segments.
274// These are resolved at load time to create corresponding FPropertyAccess entries
275USTRUCT()
277{
279
281 : PathSegmentStartIndex(INDEX_NONE)
282 , PathSegmentCount(INDEX_NONE)
283 {
284 }
285
286private:
288 friend struct FPropertyAccessEditorSystem;
289
290 // Index into the library's path segments. Used to provide a starting point for a path resolve
291 UPROPERTY()
292 int32 PathSegmentStartIndex = INDEX_NONE;
293
294 // The count of the path segments.
295 UPROPERTY()
296 int32 PathSegmentCount = INDEX_NONE;
297};
298
299UENUM()
301{
302 // No copying
303 None,
304
305 // For plain old data types, we do a simple memcpy.
306 Plain,
307
308 // For more complex data types, we need to call the properties copy function
309 Complex,
310
311 // Read and write properties using bool property helpers, as source/dest could be bitfield or boolean
312 Bool,
313
314 // Use struct copy operation, as this needs to correctly handle CPP struct ops
315 Struct,
316
317 // Read and write properties using object property helpers, as source/dest could be regular/weak/soft etc.
318 Object,
319
320 // FName needs special case because its size changes between editor/compiler and runtime.
321 Name,
322
323 // Array needs special handling for fixed size arrays
324 Array,
325
326 // Promote the type during the copy
327 // Bool promotions
333
334 // Byte promotions
339
340 // Int32 promotions
342 PromoteInt32ToFloat, // This is strictly sketchy because of potential data loss, but it is usually OK in the general case
344
345 // Float promotions // LWC_TODO: Float/double should become synonyms?
347 DemoteDoubleToFloat, // LWC_TODO: This should not ship!
348
351
354};
355
356// A property copy, represents a one-to-many copy operation
357USTRUCT()
359{
361
363
364private:
366 friend struct FPropertyAccessEditorSystem;
367
368 // Index into the library's Accesses
369 UPROPERTY()
370 int32 AccessIndex = INDEX_NONE;
371
372 // Index of the first of the library's DescAccesses
373 UPROPERTY()
374 int32 DestAccessStartIndex = INDEX_NONE;
375
376 // Index of the last of the library's DescAccesses
377 UPROPERTY()
378 int32 DestAccessEndIndex = INDEX_NONE;
379
380 UPROPERTY()
382};
383
384USTRUCT()
398
400USTRUCT()
402{
404
406
409
410private:
412 friend struct FPropertyAccessEditorSystem;
413
414 // All path segments in this library.
415 UPROPERTY()
416 TArray<FPropertyAccessSegment> PathSegments;
417
418 // All source paths
419 UPROPERTY()
420 TArray<FPropertyAccessPath> SrcPaths;
421
422 // All destination paths
423 UPROPERTY()
424 TArray<FPropertyAccessPath> DestPaths;
425
426#if WITH_EDITORONLY_DATA
427 UPROPERTY()
429#endif
430
431 // All copy operations
432 UPROPERTY()
433 TArray<FPropertyAccessCopyBatch> CopyBatchArray;
434
435 // All source property accesses
437
438 // All destination accesses (that are copied to our instances).
440
441 // Indirections
443
444 // Whether this library has been post-loaded
445 bool bHasBeenPostLoaded = false;
446};
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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 ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
EPropertyAccessCopyBatch
Definition PropertyAccess.h:19
EPropertyAccessObjectType
Definition PropertyAccess.h:108
EPropertyAccessCopyType
Definition PropertyAccess.h:301
EPropertyAccessSegmentFlags
Definition PropertyAccess.h:196
EPropertyAccessIndirectionType
Definition PropertyAccess.h:88
uint32 Offset
Definition VulkanMemory.cpp:4033
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NameTypes.h:617
Definition UnrealType.h:174
Definition ArrayView.h:139
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition Class.h:3793
Definition Class.h:2476
Definition Object.h:95
Definition Class.h:480
Definition PropertyAccess.cpp:11
void BindEvents(UObject *InObject, const FPropertyAccessLibrary &InLibrary)
Definition PropertyAccess.cpp:763
int32 GetEventId(const UClass *InClass, TArrayView< const FName > InPath)
Definition PropertyAccess.cpp:767
void ProcessCopy(UObject *InObject, const FPropertyAccessLibrary &InLibrary, EPropertyAccessCopyBatch InBatchType, int32 InCopyIndex, TFunctionRef< void(const FProperty *, void *)> InPostCopyOperation)
Definition PropertyAccess.cpp:748
void ProcessCopies(UObject *InObject, const FPropertyAccessLibrary &InLibrary, EPropertyAccessCopyBatch InBatchType)
Definition PropertyAccess.cpp:738
void GetAccessAddress(UObject *InObject, const FPropertyAccessLibrary &InLibrary, int32 InAccessIndex, TFunctionRef< void(const FProperty *, void *)> InFunction)
Definition PropertyAccess.cpp:758
void PatchPropertyOffsets(FPropertyAccessLibrary &InLibrary)
Definition PropertyAccess.cpp:733
void PostLoadLibrary(FPropertyAccessLibrary &InLibrary)
Definition PropertyAccess.cpp:728
@ false
Definition radaudio_common.h:23
Definition PropertyAccess.h:386
Definition PropertyAccess.h:359
Definition PropertyAccess.h:172
Definition PropertyAccess.h:128
Definition PropertyAccess.h:402
Definition PropertyAccess.h:277
Definition PropertyAccess.h:239
Definition PropertyAccess.cpp:16
Definition PropertyAccess.h:39
FCopyBatchId(int32 InId)
Definition PropertyAccess.h:40
int32 Id
Definition PropertyAccess.h:44
Definition FieldPath.h:283
Definition ObjectPtr.h:488