Added script inspector and serialization support for RigAsset and AnimationClipAsset

This commit is contained in:
Kah Wei 2023-01-31 11:29:00 +08:00
parent a0bafcc526
commit 933e963950
4 changed files with 161 additions and 113 deletions

View File

@ -18,6 +18,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Editor/Editor.hxx" #include "Editor/Editor.hxx"
// STL Includes // STL Includes
#include <memory> #include <memory>
#include <string>
// Project Headers // Project Headers
#include "Components/Component.hxx" #include "Components/Component.hxx"
#include "Scripts/ScriptStore.hxx" #include "Scripts/ScriptStore.hxx"
@ -30,7 +31,8 @@ of DigiPen Institute of Technology is prohibited.
#include "RangeAttribute.hxx" #include "RangeAttribute.hxx"
#include "Math/Vector2.hxx" #include "Math/Vector2.hxx"
#include "Math/Vector3.hxx" #include "Math/Vector3.hxx"
#include <string> #include "Assets/RigAsset.hxx"
#include "Assets/AnimationClipAsset.hxx"
// Using Directives // Using Directives
using namespace System; using namespace System;
@ -175,11 +177,13 @@ namespace SHADE
renderSpecificField<SHVec2 , Vector2 >(field, object, SHEditorUI::InputVec2 , &isHovered) || renderSpecificField<SHVec2 , Vector2 >(field, object, SHEditorUI::InputVec2 , &isHovered) ||
renderSpecificField<SHVec3 , Vector3 >(field, object, SHEditorUI::InputVec3 , &isHovered) || renderSpecificField<SHVec3 , Vector3 >(field, object, SHEditorUI::InputVec3 , &isHovered) ||
renderSpecificField<uint32_t , GameObject >(field, object, nullptr , &isHovered) || renderSpecificField<uint32_t , GameObject >(field, object, nullptr , &isHovered) ||
renderSpecificField<std::string, System::String^>(field, object, nullptr , &isHovered) || renderSpecificField<std::string, System::String^ >(field, object, nullptr , &isHovered) ||
renderSpecificField<int , System::Enum >(field, object, nullptr , &isHovered) || renderSpecificField<int , System::Enum >(field, object, nullptr , &isHovered) ||
renderSpecificField<AssetID , FontAsset >(field, object, nullptr , &isHovered) || renderSpecificField<AssetID , FontAsset >(field, object, nullptr , &isHovered) ||
renderSpecificField<AssetID , MeshAsset >(field, object, nullptr , &isHovered) || renderSpecificField<AssetID , MeshAsset >(field, object, nullptr , &isHovered) ||
renderSpecificField<AssetID , MaterialAsset >(field, object, nullptr , &isHovered); renderSpecificField<AssetID , MaterialAsset >(field, object, nullptr , &isHovered) ||
renderSpecificField<AssetID , RigAsset >(field, object, nullptr , &isHovered) ||
renderSpecificField<AssetID , AnimationClipAsset>(field, object, nullptr , &isHovered);
if (!MODIFIED_PRIMITIVE) if (!MODIFIED_PRIMITIVE)
{ {
@ -336,11 +340,13 @@ namespace SHADE
renderFieldEditor<SHVec2 , Vector2 >(fieldName, object, SHEditorUI::InputVec2 , nullptr, rangeAttrib, modified) || renderFieldEditor<SHVec2 , Vector2 >(fieldName, object, SHEditorUI::InputVec2 , nullptr, rangeAttrib, modified) ||
renderFieldEditor<SHVec3 , Vector3 >(fieldName, object, SHEditorUI::InputVec3 , nullptr, rangeAttrib, modified) || renderFieldEditor<SHVec3 , Vector3 >(fieldName, object, SHEditorUI::InputVec3 , nullptr, rangeAttrib, modified) ||
renderFieldEditor<uint32_t , GameObject >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) || renderFieldEditor<uint32_t , GameObject >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
renderFieldEditor<std::string, System::String^>(fieldName, object, nullptr , nullptr, rangeAttrib, modified) || renderFieldEditor<std::string, System::String^ >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
renderFieldEditor<int , System::Enum >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) || renderFieldEditor<int , System::Enum >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
renderFieldEditor<AssetID , FontAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) || renderFieldEditor<AssetID , FontAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
renderFieldEditor<AssetID , MeshAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) || renderFieldEditor<AssetID , MeshAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
renderFieldEditor<AssetID , MaterialAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified); renderFieldEditor<AssetID , MaterialAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified)||
renderFieldEditor<AssetID , RigAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
renderFieldEditor<AssetID , AnimationClipAsset>(fieldName, object, nullptr , nullptr, rangeAttrib, modified);
return modified; return modified;
} }

View File

@ -23,6 +23,8 @@ of DigiPen Institute of Technology is prohibited.
#include "Assets/FontAsset.hxx" #include "Assets/FontAsset.hxx"
#include "Assets/MeshAsset.hxx" #include "Assets/MeshAsset.hxx"
#include "Assets/MaterialAsset.hxx" #include "Assets/MaterialAsset.hxx"
#include "Assets/RigAsset.hxx"
#include "Assets/AnimationClipAsset.hxx"
namespace SHADE namespace SHADE
{ {
@ -237,6 +239,30 @@ namespace SHADE
return true; return true;
} }
return false;
}
template<>
bool Editor::renderFieldEditorInternal<AssetID, RigAsset>(const std::string& fieldName, interior_ptr<RigAsset> managedValPtr, EditorFieldFunc<uint32_t>, bool* isHovered, RangeAttribute^)
{
uint32_t assetId = managedValPtr->NativeAssetID;
if (SHEditorUI::InputAssetField(fieldName, assetId, AssetType::MODEL, isHovered))
{
*managedValPtr = RigAsset(assetId);
return true;
}
return false;
}
template<>
bool Editor::renderFieldEditorInternal<AssetID, AnimationClipAsset>(const std::string& fieldName, interior_ptr<AnimationClipAsset> managedValPtr, EditorFieldFunc<uint32_t>, bool* isHovered, RangeAttribute^)
{
uint32_t assetId = managedValPtr->NativeAssetID;
if (SHEditorUI::InputAssetField(fieldName, assetId, AssetType::MODEL, isHovered))
{
*managedValPtr = AnimationClipAsset(assetId);
return true;
}
return false; return false;
} }
} }

View File

@ -22,6 +22,8 @@ of DigiPen Institute of Technology is prohibited.
#include "Assets/MaterialAsset.hxx" #include "Assets/MaterialAsset.hxx"
#include "Assets/MeshAsset.hxx" #include "Assets/MeshAsset.hxx"
#include "Scripts/Script.hxx" #include "Scripts/Script.hxx"
#include "Assets/RigAsset.hxx"
#include "Assets/AnimationClipAsset.hxx"
/*-------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------*/
/* File-Level Constants */ /* File-Level Constants */
@ -147,21 +149,23 @@ namespace SHADE
const bool PRIMITIVE_SERIALIZED = fieldInsertYaml<System::Int16 >(fieldInfo, object, fieldNode) || const bool PRIMITIVE_SERIALIZED = fieldInsertYaml<System::Int16 >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<System::Int32 >(fieldInfo, object, fieldNode) || fieldInsertYaml<System::Int32 >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<System::Int64 >(fieldInfo, object, fieldNode) || fieldInsertYaml<System::Int64 >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<System::UInt16>(fieldInfo, object, fieldNode) || fieldInsertYaml<System::UInt16 >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<System::UInt32>(fieldInfo, object, fieldNode) || fieldInsertYaml<System::UInt32 >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<System::UInt64>(fieldInfo, object, fieldNode) || fieldInsertYaml<System::UInt64 >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<System::Byte >(fieldInfo, object, fieldNode) || fieldInsertYaml<System::Byte >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<bool >(fieldInfo, object, fieldNode) || fieldInsertYaml<bool >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<float >(fieldInfo, object, fieldNode) || fieldInsertYaml<float >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<double >(fieldInfo, object, fieldNode) || fieldInsertYaml<double >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<System::Enum >(fieldInfo, object, fieldNode) || fieldInsertYaml<System::Enum >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<System::String>(fieldInfo, object, fieldNode) || fieldInsertYaml<System::String >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<Vector2 >(fieldInfo, object, fieldNode) || fieldInsertYaml<Vector2 >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<Vector3 >(fieldInfo, object, fieldNode) || fieldInsertYaml<Vector3 >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<GameObject >(fieldInfo, object, fieldNode) || fieldInsertYaml<GameObject >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<FontAsset >(fieldInfo, object, fieldNode) || fieldInsertYaml<FontAsset >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<MaterialAsset >(fieldInfo, object, fieldNode) || fieldInsertYaml<MaterialAsset >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<MeshAsset >(fieldInfo, object, fieldNode); fieldInsertYaml<MeshAsset >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<RigAsset >(fieldInfo, object, fieldNode) ||
fieldInsertYaml<AnimationClipAsset>(fieldInfo, object, fieldNode);
// Serialization of more complex types // Serialization of more complex types
if (!PRIMITIVE_SERIALIZED) if (!PRIMITIVE_SERIALIZED)
@ -211,21 +215,23 @@ namespace SHADE
varInsertYamlInternal<System::Int16 >(object, fieldNode) || varInsertYamlInternal<System::Int16 >(object, fieldNode) ||
varInsertYamlInternal<System::Int32 >(object, fieldNode) || varInsertYamlInternal<System::Int32 >(object, fieldNode) ||
varInsertYamlInternal<System::Int64 >(object, fieldNode) || varInsertYamlInternal<System::Int64 >(object, fieldNode) ||
varInsertYamlInternal<System::UInt16>(object, fieldNode) || varInsertYamlInternal<System::UInt16 >(object, fieldNode) ||
varInsertYamlInternal<System::UInt32>(object, fieldNode) || varInsertYamlInternal<System::UInt32 >(object, fieldNode) ||
varInsertYamlInternal<System::UInt64>(object, fieldNode) || varInsertYamlInternal<System::UInt64 >(object, fieldNode) ||
varInsertYamlInternal<System::Byte >(object, fieldNode) || varInsertYamlInternal<System::Byte >(object, fieldNode) ||
varInsertYamlInternal<bool >(object, fieldNode) || varInsertYamlInternal<bool >(object, fieldNode) ||
varInsertYamlInternal<float >(object, fieldNode) || varInsertYamlInternal<float >(object, fieldNode) ||
varInsertYamlInternal<double >(object, fieldNode) || varInsertYamlInternal<double >(object, fieldNode) ||
varInsertYamlInternal<System::Enum >(object, fieldNode) || varInsertYamlInternal<System::Enum >(object, fieldNode) ||
varInsertYamlInternal<System::String>(object, fieldNode) || varInsertYamlInternal<System::String >(object, fieldNode) ||
varInsertYamlInternal<Vector2 >(object, fieldNode) || varInsertYamlInternal<Vector2 >(object, fieldNode) ||
varInsertYamlInternal<Vector3 >(object, fieldNode) || varInsertYamlInternal<Vector3 >(object, fieldNode) ||
varInsertYamlInternal<GameObject >(object, fieldNode) || varInsertYamlInternal<GameObject >(object, fieldNode) ||
varInsertYamlInternal<FontAsset >(object, fieldNode) || varInsertYamlInternal<FontAsset >(object, fieldNode) ||
varInsertYamlInternal<MaterialAsset >(object, fieldNode) || varInsertYamlInternal<MaterialAsset >(object, fieldNode) ||
varInsertYamlInternal<MeshAsset >(object, fieldNode); varInsertYamlInternal<MeshAsset >(object, fieldNode) ||
varInsertYamlInternal<RigAsset >(object, fieldNode) ||
varInsertYamlInternal<AnimationClipAsset>(object, fieldNode);
return INSERTED; return INSERTED;
} }
@ -238,21 +244,23 @@ namespace SHADE
fieldAssignYaml<System::Int16> (fieldInfo, object, node) || fieldAssignYaml<System::Int16> (fieldInfo, object, node) ||
fieldAssignYaml<System::Int32> (fieldInfo, object, node) || fieldAssignYaml<System::Int32> (fieldInfo, object, node) ||
fieldAssignYaml<System::Int64> (fieldInfo, object, node) || fieldAssignYaml<System::Int64> (fieldInfo, object, node) ||
fieldAssignYaml<System::UInt16>(fieldInfo, object, node) || fieldAssignYaml<System::UInt16> (fieldInfo, object, node) ||
fieldAssignYaml<System::UInt32>(fieldInfo, object, node) || fieldAssignYaml<System::UInt32> (fieldInfo, object, node) ||
fieldAssignYaml<System::UInt64>(fieldInfo, object, node) || fieldAssignYaml<System::UInt64> (fieldInfo, object, node) ||
fieldAssignYaml<System::Byte> (fieldInfo, object, node) || fieldAssignYaml<System::Byte> (fieldInfo, object, node) ||
fieldAssignYaml<bool> (fieldInfo, object, node) || fieldAssignYaml<bool> (fieldInfo, object, node) ||
fieldAssignYaml<float> (fieldInfo, object, node) || fieldAssignYaml<float> (fieldInfo, object, node) ||
fieldAssignYaml<double> (fieldInfo, object, node) || fieldAssignYaml<double> (fieldInfo, object, node) ||
fieldAssignYaml<System::Enum> (fieldInfo, object, node) || fieldAssignYaml<System::Enum> (fieldInfo, object, node) ||
fieldAssignYaml<System::String>(fieldInfo, object, node) || fieldAssignYaml<System::String> (fieldInfo, object, node) ||
fieldAssignYaml<Vector2> (fieldInfo, object, node) || fieldAssignYaml<Vector2> (fieldInfo, object, node) ||
fieldAssignYaml<Vector3> (fieldInfo, object, node) || fieldAssignYaml<Vector3> (fieldInfo, object, node) ||
fieldAssignYaml<GameObject> (fieldInfo, object, node) || fieldAssignYaml<GameObject> (fieldInfo, object, node) ||
fieldAssignYaml<FontAsset> (fieldInfo, object, node) || fieldAssignYaml<FontAsset> (fieldInfo, object, node) ||
fieldAssignYaml<MaterialAsset> (fieldInfo, object, node) || fieldAssignYaml<MaterialAsset> (fieldInfo, object, node) ||
fieldAssignYaml<MeshAsset> (fieldInfo, object, node); fieldAssignYaml<MeshAsset> (fieldInfo, object, node) ||
fieldAssignYaml<RigAsset> (fieldInfo, object, node) ||
fieldAssignYaml<AnimationClipAsset>(fieldInfo, object, node);
if (!ASSIGNED) if (!ASSIGNED)
{ {
if (ReflectionUtilities::FieldIsList(fieldInfo)) if (ReflectionUtilities::FieldIsList(fieldInfo))
@ -312,21 +320,23 @@ namespace SHADE
varAssignYamlInternal<System::Int16> (object, node) || varAssignYamlInternal<System::Int16> (object, node) ||
varAssignYamlInternal<System::Int32> (object, node) || varAssignYamlInternal<System::Int32> (object, node) ||
varAssignYamlInternal<System::Int64> (object, node) || varAssignYamlInternal<System::Int64> (object, node) ||
varAssignYamlInternal<System::UInt16>(object, node) || varAssignYamlInternal<System::UInt16> (object, node) ||
varAssignYamlInternal<System::UInt32>(object, node) || varAssignYamlInternal<System::UInt32> (object, node) ||
varAssignYamlInternal<System::UInt64>(object, node) || varAssignYamlInternal<System::UInt64> (object, node) ||
varAssignYamlInternal<System::Byte> (object, node) || varAssignYamlInternal<System::Byte> (object, node) ||
varAssignYamlInternal<bool> (object, node) || varAssignYamlInternal<bool> (object, node) ||
varAssignYamlInternal<float> (object, node) || varAssignYamlInternal<float> (object, node) ||
varAssignYamlInternal<double> (object, node) || varAssignYamlInternal<double> (object, node) ||
varAssignYamlInternal<System::Enum> (object, node) || varAssignYamlInternal<System::Enum> (object, node) ||
varAssignYamlInternal<System::String>(object, node) || varAssignYamlInternal<System::String> (object, node) ||
varAssignYamlInternal<Vector2> (object, node) || varAssignYamlInternal<Vector2> (object, node) ||
varAssignYamlInternal<Vector3> (object, node) || varAssignYamlInternal<Vector3> (object, node) ||
varAssignYamlInternal<GameObject> (object, node) || varAssignYamlInternal<GameObject> (object, node) ||
varAssignYamlInternal<FontAsset> (object, node) || varAssignYamlInternal<FontAsset> (object, node) ||
varAssignYamlInternal<MaterialAsset> (object, node) || varAssignYamlInternal<MaterialAsset> (object, node) ||
varAssignYamlInternal<MeshAsset> (object, node); varAssignYamlInternal<MeshAsset> (object, node) ||
varAssignYamlInternal<RigAsset> (object, node) ||
varAssignYamlInternal<AnimationClipAsset>(object, node);
return DESERIALISED; return DESERIALISED;
} }
} }

View File

@ -62,7 +62,9 @@ namespace SHADE
} }
else if constexpr (std::is_same_v<FieldType, FontAsset> || else if constexpr (std::is_same_v<FieldType, FontAsset> ||
std::is_same_v<FieldType, MaterialAsset> || std::is_same_v<FieldType, MaterialAsset> ||
std::is_same_v<FieldType, MeshAsset>) std::is_same_v<FieldType, MeshAsset> ||
std::is_same_v<FieldType, RigAsset> ||
std::is_same_v<FieldType, AnimationClipAsset>)
{ {
fieldNode = INVALID_ASSET_ID; fieldNode = INVALID_ASSET_ID;
} }
@ -130,7 +132,9 @@ namespace SHADE
} }
else if constexpr (std::is_same_v<FieldType, FontAsset> || else if constexpr (std::is_same_v<FieldType, FontAsset> ||
std::is_same_v<FieldType, MaterialAsset> || std::is_same_v<FieldType, MaterialAsset> ||
std::is_same_v<FieldType, MeshAsset>) std::is_same_v<FieldType, MeshAsset> ||
std::is_same_v<FieldType, RigAsset> ||
std::is_same_v<FieldType, AnimationClipAsset>)
{ {
if (object->GetType() == FieldType::typeid) if (object->GetType() == FieldType::typeid)
{ {
@ -256,7 +260,9 @@ namespace SHADE
} }
else if constexpr (std::is_same_v<FieldType, FontAsset> || else if constexpr (std::is_same_v<FieldType, FontAsset> ||
std::is_same_v<FieldType, MaterialAsset> || std::is_same_v<FieldType, MaterialAsset> ||
std::is_same_v<FieldType, MeshAsset>) std::is_same_v<FieldType, MeshAsset> ||
std::is_same_v<FieldType, RigAsset> ||
std::is_same_v<FieldType, AnimationClipAsset>)
{ {
if (object->GetType() == FieldType::typeid) if (object->GetType() == FieldType::typeid)
{ {