Added C# Assets System and Serialization of Script Enabled State #247
|
@ -18,6 +18,9 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Serialisation/SerialisationUtilities.hxx"
|
||||
// Project Includes
|
||||
#include "ReflectionUtilities.hxx"
|
||||
#include "Assets/FontAsset.hxx"
|
||||
#include "Assets/MaterialAsset.hxx"
|
||||
#include "Assets/MeshAsset.hxx"
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
/* File-Level Constants */
|
||||
|
@ -129,7 +132,10 @@ namespace SHADE
|
|||
fieldInsertYaml<System::String>(fieldInfo, object, fieldNode) ||
|
||||
fieldInsertYaml<Vector2 >(fieldInfo, object, fieldNode) ||
|
||||
fieldInsertYaml<Vector3 >(fieldInfo, object, fieldNode) ||
|
||||
fieldInsertYaml<GameObject >(fieldInfo, object, fieldNode);
|
||||
fieldInsertYaml<GameObject >(fieldInfo, object, fieldNode) ||
|
||||
fieldInsertYaml<FontAsset >(fieldInfo, object, fieldNode) ||
|
||||
fieldInsertYaml<MaterialAsset >(fieldInfo, object, fieldNode) ||
|
||||
fieldInsertYaml<MeshAsset >(fieldInfo, object, fieldNode);
|
||||
|
||||
// Serialization of more complex types
|
||||
if (!PRIMITIVE_SERIALIZED)
|
||||
|
@ -190,7 +196,10 @@ namespace SHADE
|
|||
varInsertYamlInternal<System::String>(object, fieldNode) ||
|
||||
varInsertYamlInternal<Vector2 >(object, fieldNode) ||
|
||||
varInsertYamlInternal<Vector3 >(object, fieldNode) ||
|
||||
varInsertYamlInternal<GameObject >(object, fieldNode);
|
||||
varInsertYamlInternal<GameObject >(object, fieldNode) ||
|
||||
varInsertYamlInternal<FontAsset >(object, fieldNode) ||
|
||||
varInsertYamlInternal<MaterialAsset >(object, fieldNode) ||
|
||||
varInsertYamlInternal<MeshAsset >(object, fieldNode);
|
||||
return INSERTED;
|
||||
}
|
||||
|
||||
|
@ -214,7 +223,10 @@ namespace SHADE
|
|||
fieldAssignYaml<System::String>(fieldInfo, object, node) ||
|
||||
fieldAssignYaml<Vector2> (fieldInfo, object, node) ||
|
||||
fieldAssignYaml<Vector3> (fieldInfo, object, node) ||
|
||||
fieldAssignYaml<GameObject> (fieldInfo, object, node);
|
||||
fieldAssignYaml<GameObject> (fieldInfo, object, node) ||
|
||||
fieldAssignYaml<FontAsset> (fieldInfo, object, node) ||
|
||||
fieldAssignYaml<MaterialAsset> (fieldInfo, object, node) ||
|
||||
fieldAssignYaml<MeshAsset> (fieldInfo, object, node);
|
||||
if (!ASSIGNED)
|
||||
{
|
||||
if (ReflectionUtilities::FieldIsList(fieldInfo))
|
||||
|
@ -277,7 +289,10 @@ namespace SHADE
|
|||
varAssignYamlInternal<System::String>(object, node) ||
|
||||
varAssignYamlInternal<Vector2> (object, node) ||
|
||||
varAssignYamlInternal<Vector3> (object, node) ||
|
||||
varAssignYamlInternal<GameObject> (object, node);
|
||||
varAssignYamlInternal<GameObject> (object, node) ||
|
||||
varAssignYamlInternal<FontAsset> (object, node) ||
|
||||
varAssignYamlInternal<MaterialAsset> (object, node) ||
|
||||
varAssignYamlInternal<MeshAsset> (object, node);
|
||||
return DESERIALISED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,12 @@ namespace SHADE
|
|||
{
|
||||
fieldNode = MAX_EID;
|
||||
}
|
||||
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
||||
std::is_same_v<FieldType, MaterialAsset> ||
|
||||
std::is_same_v<FieldType, MeshAsset>)
|
||||
{
|
||||
fieldNode = INVALID_ASSET_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldNode = FieldType();
|
||||
|
@ -122,6 +128,17 @@ namespace SHADE
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
||||
std::is_same_v<FieldType, MaterialAsset> ||
|
||||
std::is_same_v<FieldType, MeshAsset>)
|
||||
{
|
||||
if (object->GetType() == FieldType::typeid)
|
||||
{
|
||||
FieldType asset = safe_cast<FieldType>(object);
|
||||
fieldNode = asset.NativeAssetID;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (object->GetType() == FieldType::typeid)
|
||||
|
@ -229,6 +246,16 @@ namespace SHADE
|
|||
const uint32_t EID = node.as<uint32_t>();
|
||||
object = (EID == MAX_EID ? GameObject() : GameObject(EID));
|
||||
}
|
||||
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
||||
std::is_same_v<FieldType, MaterialAsset> ||
|
||||
std::is_same_v<FieldType, MeshAsset>)
|
||||
{
|
||||
if (object->GetType() == FieldType::typeid)
|
||||
{
|
||||
object = FieldType(node.as<AssetID>());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
object = node.as<CastType>();
|
||||
|
|
Loading…
Reference in New Issue