UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MovieSceneEvalTemplateSerializer.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"
6#include "Misc/InlineValue.h"
7#include "MovieSceneFwd.h"
10
12
14template<typename T, uint16 N>
16{
17 Ar.UsingCustomVersion(FMovieSceneEvaluationCustomVersion::GUID);
18
19 if (Ar.IsLoading())
20 {
21 FString TypeName;
22 Ar << TypeName;
23
24 // If it's empty, then we've got nothing
25 if (TypeName.IsEmpty())
26 {
27 return true;
28 }
29
30 // Find the script struct of the thing that was serialized
31 UScriptStruct* Struct = FindObject<UScriptStruct>(nullptr, *TypeName);
32 if (!Struct)
33 {
34 if (bWarnOnError)
35 {
36 // We only throw this warning in cooked builds as that is the only place where this deserialized data matters
37 UE_LOG(LogMovieScene, Warning, TEXT("Unknown or invalid type (%s) found in serialized data. This will no longer work."), *TypeName);
38 }
39
40 // If it wasn't found, just deserialize an empty struct instead, and set ourselves to default
42 FMovieSceneEmptyStruct::StaticStruct()->SerializeItem(Ar, &Empty, nullptr);
43 return true;
44 }
45
46 int32 StructSize = Struct->GetCppStructOps()->GetSize();
47 int32 StructAlignment = Struct->GetCppStructOps()->GetAlignment();
48 void* Allocation = Impl.Reserve(StructSize, StructAlignment);
49
50 Struct->GetCppStructOps()->Construct(Allocation);
51 Struct->SerializeItem(Ar, Allocation, nullptr);
52
53 return true;
54 }
55 else if (Ar.IsSaving())
56 {
57 if (Impl.IsValid())
58 {
59 auto* ImplPtr = &Impl.GetValue();
60 UScriptStruct& Struct = ImplPtr->GetScriptStruct();
61 FString TypeName = Struct.GetPathName();
62 Ar << TypeName;
63
64 Struct.SerializeItem(Ar, ImplPtr, nullptr);
65 }
66 else
67 {
68 // Just serialize an empty name
69 FString Name;
70 Ar << Name;
71 }
72
73 return true;
74 }
75
76 return false;
77}
#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 UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
bool SerializeInlineValue(TInlineValue< T, N > &Impl, FArchive &Ar, bool bWarnOnError)
Definition MovieSceneEvalTemplateSerializer.h:15
Definition Archive.h:1208
virtual CORE_API void UsingCustomVersion(const struct FGuid &Guid)
Definition Archive.cpp:590
UE_FORCEINLINE_HINT bool IsLoading() const
Definition Archive.h:236
UE_FORCEINLINE_HINT bool IsSaving() const
Definition Archive.h:248
Definition InlineValue.h:22
COREUOBJECT_API FString GetPathName(const UObject *StopOuter=NULL) const
Definition UObjectBaseUtility.cpp:38
Definition Class.h:1720
Definition ExpressionParserTypes.h:21
Definition MovieSceneEvalTemplateBase.h:18