From 5cc0cc9ee76a05c6077b3e85bd38e203ff181688 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Fri, 14 May 2021 11:03:31 -0500 Subject: [PATCH] Fixed the loading of uicanvas assets due to the NetBindable class being (#755) removed from the SerializeContext. The TransformComponent and ScriptComponent which used to Serialize a NetBindable instance didn't have their version numbers bumped in order to skip the old data when loading a binary ObjectStream --- .../Components/TransformComponent.cpp | 2 +- .../AzFramework/Script/ScriptComponent.cpp | 2 +- .../Code/Source/UiInteractableComponent.cpp | 1 + .../Code/Source/UiInteractableState.cpp | 26 +++++++++++++------ .../LyShine/Code/Source/UiInteractableState.h | 2 ++ .../Comp/Text/ImageMarkup.uicanvas | 2 +- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Components/TransformComponent.cpp b/Code/Framework/AzFramework/AzFramework/Components/TransformComponent.cpp index 3c05887a89..9083cb7d0d 100644 --- a/Code/Framework/AzFramework/AzFramework/Components/TransformComponent.cpp +++ b/Code/Framework/AzFramework/AzFramework/Components/TransformComponent.cpp @@ -881,7 +881,7 @@ namespace AzFramework serializeContext->ClassDeprecate("NetBindable", "{80206665-D429-4703-B42E-94434F82F381}"); serializeContext->Class() - ->Version(4, &TransformComponentVersionConverter) + ->Version(5, &TransformComponentVersionConverter) ->Field("Parent", &TransformComponent::m_parentId) ->Field("Transform", &TransformComponent::m_worldTM) ->Field("LocalTransform", &TransformComponent::m_localTM) diff --git a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp index 30343b1322..cdfad7f116 100644 --- a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp +++ b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp @@ -979,7 +979,7 @@ namespace AzFramework }; serializeContext->Class() - ->Version(3, converter) + ->Version(4, converter) ->Field("ContextID", &ScriptComponent::m_contextId) ->Field("Properties", &ScriptComponent::m_properties) ->Field("Script", &ScriptComponent::m_script) diff --git a/Gems/LyShine/Code/Source/UiInteractableComponent.cpp b/Gems/LyShine/Code/Source/UiInteractableComponent.cpp index b665bbe1dc..e4ba507340 100644 --- a/Gems/LyShine/Code/Source/UiInteractableComponent.cpp +++ b/Gems/LyShine/Code/Source/UiInteractableComponent.cpp @@ -546,6 +546,7 @@ void UiInteractableComponent::Reflect(AZ::ReflectContext* context) ->Handler(); } + UiInteractableStateAction::Reflect(context); UiInteractableStateColor::Reflect(context); UiInteractableStateAlpha::Reflect(context); UiInteractableStateSprite::Reflect(context); diff --git a/Gems/LyShine/Code/Source/UiInteractableState.cpp b/Gems/LyShine/Code/Source/UiInteractableState.cpp index f5d703d87a..965899a958 100644 --- a/Gems/LyShine/Code/Source/UiInteractableState.cpp +++ b/Gems/LyShine/Code/Source/UiInteractableState.cpp @@ -41,6 +41,16 @@ void UiInteractableStateAction::SetInteractableEntity(AZ::EntityId interactableE m_interactableEntity = interactableEntityId; } +//////////////////////////////////////////////////////////////////////////////////////////////////// +void UiInteractableStateAction::Reflect(AZ::ReflectContext* context) +{ + if (auto serializeContext = azrtti_cast(context)) + { + serializeContext->Class(); + } +} + + //////////////////////////////////////////////////////////////////////////////////////////////////// void UiInteractableStateAction::Init(AZ::EntityId interactableEntityId) { @@ -128,8 +138,8 @@ void UiInteractableStateColor::Reflect(AZ::ReflectContext* context) if (serializeContext) { - serializeContext->Class() - ->Version(2, &VersionConverter) + serializeContext->Class() + ->Version(3, &VersionConverter) ->Field("TargetEntity", &UiInteractableStateColor::m_targetEntity) ->Field("Color", &UiInteractableStateColor::m_color); @@ -223,8 +233,8 @@ void UiInteractableStateAlpha::Reflect(AZ::ReflectContext* context) if (serializeContext) { - serializeContext->Class() - ->Version(1) + serializeContext->Class() + ->Version(2) ->Field("TargetEntity", &UiInteractableStateAlpha::m_targetEntity) ->Field("Alpha", &UiInteractableStateAlpha::m_alpha); @@ -379,8 +389,8 @@ void UiInteractableStateSprite::Reflect(AZ::ReflectContext* context) if (serializeContext) { - serializeContext->Class() - ->Version(3) + serializeContext->Class() + ->Version(4) ->Field("TargetEntity", &UiInteractableStateSprite::m_targetEntity) ->Field("Sprite", &UiInteractableStateSprite::m_spritePathname) ->Field("Index", &UiInteractableStateSprite::m_spriteSheetCellIndex); @@ -633,8 +643,8 @@ void UiInteractableStateFont::Reflect(AZ::ReflectContext* context) if (serializeContext) { - serializeContext->Class() - ->Version(1) + serializeContext->Class() + ->Version(2) ->Field("TargetEntity", &UiInteractableStateFont::m_targetEntity) ->Field("FontFileName", &UiInteractableStateFont::m_fontFilename) ->Field("EffectIndex", &UiInteractableStateFont::m_fontEffectIndex); diff --git a/Gems/LyShine/Code/Source/UiInteractableState.h b/Gems/LyShine/Code/Source/UiInteractableState.h index 966c24f202..81e9ac48e1 100644 --- a/Gems/LyShine/Code/Source/UiInteractableState.h +++ b/Gems/LyShine/Code/Source/UiInteractableState.h @@ -42,6 +42,8 @@ public: // member functions virtual ~UiInteractableStateAction() {} + static void Reflect(AZ::ReflectContext* context); + //! Called from the Init of the UiInteractableComponent virtual void Init(AZ::EntityId); diff --git a/Gems/LyShineExamples/Assets/UI/Canvases/LyShineExamples/Comp/Text/ImageMarkup.uicanvas b/Gems/LyShineExamples/Assets/UI/Canvases/LyShineExamples/Comp/Text/ImageMarkup.uicanvas index 2e3ab0121f..3bcd4f3db3 100644 --- a/Gems/LyShineExamples/Assets/UI/Canvases/LyShineExamples/Comp/Text/ImageMarkup.uicanvas +++ b/Gems/LyShineExamples/Assets/UI/Canvases/LyShineExamples/Comp/Text/ImageMarkup.uicanvas @@ -56,7 +56,7 @@ - +