Serialization Helpers
Categories:
Three helpers that eliminate serialization boilerplate: a single-include header for common reflection, an extension for asset fields, and a ready-made O3DE asset handler template for any custom AssetData subclass.
For usage guides and setup examples, see The Basics: GS_Core.
Contents
GS_ReflectionIncludes.h
A single-include header that brings in all O3DE reflection headers needed for any class with an inline Reflect() method.
Includes:
AzCore/RTTI/RTTI.hAzCore/Memory/SystemAllocator.hAzCore/Serialization/SerializeContext.hAzCore/Serialization/EditContext.hAzCore/std/string/string.h
Use this in any header declaring a reflected struct, class, or enum. Does not handle AZ::Data::Asset<T> fields.
#include <GS_Core/Utility/Reflection/GS_ReflectionIncludes.h>
namespace MyProject
{
struct MyData
{
AZ_TYPE_INFO(MyData, "{YOUR-UUID-HERE}");
static void Reflect(AZ::ReflectContext* context);
float m_value = 0.0f;
};
}
GS_AssetReflectionIncludes.h
Extends GS_ReflectionIncludes.h with asset serialization headers.
Adds:
AzCore/Asset/AssetCommon.hAzCore/Asset/AssetSerializer.h
Use this in any header declaring a class with AZ::Data::Asset<T> fields. Ensures SerializeGenericTypeInfo<Asset<T>> is visible and prevents silent failures in Unity builds.
#include <GS_Core/Utility/Reflection/GS_AssetReflectionIncludes.h>
namespace MyProject
{
struct MyComponent : public AZ::Component
{
AZ_COMPONENT_DECL(MyComponent);
static void Reflect(AZ::ReflectContext* context);
AZ::Data::Asset<MyAssetType> m_asset;
};
}
See Also
For related resources:
Get GS_Core
GS_Core — Explore this gem on the product page and add it to your project.