Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json serialization limitation #2584

Open
cNori opened this issue May 10, 2024 · 3 comments
Open

Json serialization limitation #2584

cNori opened this issue May 10, 2024 · 3 comments
Milestone

Comments

@cNori
Copy link
Contributor

cNori commented May 10, 2024

Issue description:
when calling a Editor.SaveJsonAsset funcion,
seralistaion funcion is never called on c++ side

example:

//.h
class SomeAsset : public ISerializable
{
    DECLARE_SCRIPTING_TYPE_NO_SPAWN(SomeAsset);
public:
    String CppData;
    API_FIELD() String Data;
    
    API_FUNCION() ApplayData()
    {
         CppData = L"Data_";
         CppData.Append(Name);
         
    }
    // Inherited via ISerializable
    void Serialize(SerializeStream& stream, const void* otherObj) override;
    void Deserialize(ISerializable::DeserializeStream& stream, ISerializeModifier* modifier) override;
}
//.cpp
void SomeAsset::Serialize(SerializeStream& stream, const void* otherObj)
{
        SERIALIZE_GET_OTHER_OBJ(SomeAsset);
        SERIALIZE_MEMBER(Data, CppData);
        LOG_STR("Called Serialize ?");
}
void SomeAsset::Deserialize(ISerializable::DeserializeStream& stream, ISerializeModifier* modifier)
{
       DESERIALIZE_MEMBER(Data, CppData);
       if(CppData.Find(L"Data_"))
       {
           Data = CppData;
       }
       LOG_STR("Called Deserialize");
}
@mafiesto4 mafiesto4 added this to the 1.9 milestone May 16, 2024
@mafiesto4
Copy link
Member

Json assets serialization assumes that C++ and C# sides match in serializable data layout so we use C# serializer to create the asset contents. I guess, we could handle native types which implement serialization manually, the test case might be usage of GameSettings/TimeSettings/.. which have C++ serialization but were using C#-only for now inside Editor.

@mafiesto4 mafiesto4 changed the title json Serialisation bug Json serialization limitation May 16, 2024
@mafiesto4
Copy link
Member

Also, Json asset editor creates C#-only instance to view/modify/save asset. This would also need to be changed in order to handle C++ object serializer.

@cNori
Copy link
Contributor Author

cNori commented May 16, 2024

Json assets serialization assumes that C++ and C# sides match in serializable data layout so we use C# serializer to create the asset contents. I guess, we could handle native types which implement serialization manually, the test case might be usage of GameSettings/TimeSettings/.. which have C++ serialization but were using C#-only for now inside Editor.

some times there is a data with cant be exposed to c# because it is a
example:

  • external lib
  • c++ Template
  • c++ union

or the serialisation has some compression applied to it
So the Absorption of c++ and C# objects are 100% the same is wrong

Also, Json asset editor creates C#-only instance to view/modify/save asset. This would also need to be changed in order to handle C++ object serializer.

editor creates C#-only instance
ye right now i use a hack in my pluginto get the c++ serialisation working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants