u3d-community / U3D

Open-source, cross-platform 2D and 3D game engine built in C++
https://u3d.io
MIT License
154 stars 26 forks source link

Script serializer bug #64

Open nimdavirus opened 2 months ago

nimdavirus commented 2 months ago

It is impossible to save in Serializable in scripts, all Write functions return a false ( void Save(Serializer& serializer) ). For example, if I run 18_CharacterDemo.as by Urho3DPlayer.exe from batch file and save&load a scene there is also doesn't work saving, the character just rotate to 0 yaw and 0 pitch. If I run CharacterDemo from C++ it works because there are URHO3D_ATTRIBUTE.

nimdavirus commented 2 weeks ago

Fixed. You just need to change the method declarations in the ScriptInstance.cpp:

"void Load(Serializer&)" -> "void Load(VectorBuffer&)" "void Save(Serializer&)" -> "void Save(VectorBuffer&)"

and change the declarations in the script itself.

SirNate0 commented 2 weeks ago

This solution does not seem correct to me. Can you explain why it works?

nimdavirus commented 2 weeks ago

This solution does not seem correct to me. Can you explain why it works?

ScriptInstance pushes MemoryBuffer and VectorBuffer in SetScriptDataAttr and GetScriptDataAttr script executions, so I changed declarations to VectorBuffer. I don't know why Serializer doesn't work, although VectorBuffer and MemoryBuffer are relatives of Serializer