Added serialization for UI components

This commit is contained in:
Antoine Pilote
2024-09-10 23:53:29 -04:00
parent 7a5568b513
commit 0e78c7d889
3 changed files with 18 additions and 1 deletions

View File

@@ -25,4 +25,4 @@
#include "Components/SpriteComponent.h"
#include "Components/TransformComponent.h"
#include "Components/WrenScriptComponent.h"
#include "Components/UIComponent.h"

View File

@@ -1,6 +1,7 @@
#pragma once
#include "src/Core/Object/Object.h"
#include "src/Resource/UUID.h"
#include "src/Resource/Serializable.h"
namespace Nuake
{
@@ -13,5 +14,18 @@ namespace Nuake
std::string UIFilePath;
bool IsWorldSpace;
// TODO: Z-Ordering
json Serialize()
{
BEGIN_SERIALIZE();
SERIALIZE_VAL(UIFilePath);
END_SERIALIZE();
}
bool Deserialize(const json& j)
{
DESERIALIZE_VAL(UIFilePath);
return true;
}
};
}

View File

@@ -65,6 +65,8 @@ namespace Nuake
SERIALIZE_OBJECT_REF_LBL("NetScriptComponent", GetComponent<NetScriptComponent>())
if (HasComponent<NavMeshVolumeComponent>())
SERIALIZE_OBJECT_REF_LBL("NavMeshVolumeComponent", GetComponent<NavMeshVolumeComponent>())
if (HasComponent<UIComponent>())
SERIALIZE_OBJECT_REF_LBL("UIComponent", GetComponent<UIComponent>())
END_SERIALIZE();
}
@@ -99,6 +101,7 @@ namespace Nuake
DESERIALIZE_COMPONENT(AudioEmitterComponent);
DESERIALIZE_COMPONENT(NetScriptComponent);
DESERIALIZE_COMPONENT(NavMeshVolumeComponent);
DESERIALIZE_COMPONENT(UIComponent);
return true;
}